Sort of like a touch-activated giver, but restricted to owners of a particular Gamepass.
Any help?
Sort of like a touch-activated giver, but restricted to owners of a particular Gamepass.
Any help?
Refer to this link for the gamepass information: http://wiki.roblox.com/index.php?title=API:Class/GamePassService/PlayerHasPass
But the basics are pretty much doing a hit or touch function to check if the player has the pass then cloning the tool and putting it in their backpack if they do.
Edit For Script:
script.Parent.Touched:connect(function(hit)
local id = 1315507696
if game:GetService("GamePassService"):PlayerHasPass(hit.Parent.Parent, id) then
game.ReplicatedStorage["VIP S"].Clone().Parent = hit.Parent.Parent.Backpack
end
end)
script.Parent.Touched:connect(function(hit)
local id = 1315507696
game.Players.PlayerAdded:connect(function(player)
if game:GetService("GamePassService"):PlayerHasPass(player, id) then
print(player.Name .. " has the game pass!")
else
print(player.Name .. " doesn't have the game pass...")
end
end)
if PlayerHasPass then game.ReplicatedStorage.VIP S.:Clone().Parent = hit.Parent.Parent.Backpack
end
This wouldn't work as you're using two functions.Remove the PlayerAdded function. Also, the if statement at the bottom isn't necessary. Just put the Clone line under the first if statement. You can also remove the else and prints.
Ill put a fixed one in my answer for you.
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
I think I understand, but I'm failing miserably at writing this. Could you either give me more advise or write it to better understand?
Make a function like script.Parent.Touched:connect(function(hit). Then use the link that I gave you and use an if statement for PlayerHasPass and put something like game.ReplicatedStorage.NameOfTool:Clone().Parent = hit.Parent.Parent.Backpack.
Can you take a look at what I wrote? It's my "answer" below.
Thank you. I learned something too.
No problem.