Ad
Log in to vote
0

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

Asked by 6 months ago

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

Any help?

2 answers

Log in to vote
0
Answered by 6 months ago
Edited 6 months ago

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)
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? Hiremetobuildforyou 6 — 6mo
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. Conquesias 85 — 6mo
0
Can you take a look at what I wrote? It's my "answer" below. Hiremetobuildforyou 6 — 6mo
0
Thank you. I learned something too. Hiremetobuildforyou 6 — 6mo
0
No problem. Conquesias 85 — 6mo
Ad
Log in to vote
0
Answered by 6 months ago
Edited 6 months ago
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
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. Conquesias 85 — 6mo
0
Ill put a fixed one in my answer for you. Conquesias 85 — 6mo

Answer this question