Hello, I'm Siewva for 3 years a roblox scripter. I really want, to help people with scripting. Hopefully you enjoy this.
Message me on discord if you need help. Siewva#8888
All Staps (6):
Stap: 1
game.Players.PlayerAdded:Connect(function(Player)
-- We now have the player detected.
end)
Stap: 2
Player.CharacterAdded:Connect(function(Character)
-- We now have detected our Character.
end)
Stap: 3
local function CheckGamepass(PlayerId, AssetId)
local MarketPlace = game:GetService("MarketplaceService")
if MarketPlace:UserOwnsGamePassAsync(PlayerId, AssetId) then
return true
end
return false
end
Stap: 4
local function AddTool(Player, Tool)
local Location = game.ServerStorage
if Location then
local GamepassTool = Location:FindFirstChild(Tool)
if GamepassTool then
local NewTool = GamepassTool:Clone()
NewTool.Parent = Player:WaitForChild("Backpack")
Player:LoadCharacter()
else
warn("Tool doesn't exit into the location.")
end
else
warn("Cannot find Location for the gamepass tools.")
end
end
Stap: 5
local function CheckGamepass(PlayerId, AssetId)
local MarketPlace = game:GetService("MarketplaceService")
if MarketPlace:UserOwnsGamePassAsync(PlayerId, AssetId) then
return true
end
return false
end
local function AddTool(Player, Tool)
local Location = game.ServerStorage
if Location then
local GamepassTool = Location:FindFirstChild(Tool)
if GamepassTool then
local NewTool = GamepassTool:Clone()
NewTool.Parent = Player:WaitForChild("Backpack")
Player:LoadCharacter()
else
warn("Tool doesn't exit into the location.")
end
else
warn("Cannot find Location for the gamepass tools.")
end
end
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if CheckGamepass(Player.UserId, 1234567) then
AddTool(Player, 'Glock-18')
end
end)
end)
Stap: 6
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if CheckGamepass(Player.UserId, 1234567) then
AddTool(Player, 'Glock-18')
elseif CheckGamepass(Player.UserId, 1234567) then
AddTool(Player, 'BoomBox')
elseif CheckGamepass(Player.UserId, 1234567) then
AddTool(Player, 'EarBuds')
end
end)
end)
More Explanation And Hints:
Stap 5: You need to replace "Location = game.Servertorage" to something else, when you have the tool somewhere else, like: "Location = game.Workspace".
Stap 6: Only needed if you have more then one gamepass in your game. Don't forget to replace the names, like: "EarBuds" to "Scooter".
Remember, this script need to be in a 'Script' and not in a 'LocalScript'
Hopefully you now know how to make a Gamepass Tools script! If you want more tutorials from me, please leave a review!