Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Allowing a Gamepass owner recieve their tool by touching a part (?)

Sort of like a touch-activated giver, but restricted to owners of a particular Gamepass.

Any help?

2 answers

✓ Accepted answer

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)

5 comments

0

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?

0

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.

0

Can you take a look at what I wrote? It's my "answer" below.

0

Thank you. I learned something too.

0

No problem.

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

2 comments

0

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.

0

Ill put a fixed one in my answer for you.

This discussion is preserved as it was. New answers, comments, and votes are closed.