Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to touch part upon gamepass purchase?

Asked by 2 years ago

Basically I want to make a part that gives more speed when you buy a game pass. I want the player to be able to change speeds so how can I make it that when someone buys a game pass it let's them touch the part, if they don't but the game pass they can't touch.

1 answer

Log in to vote
0
Answered by 2 years ago

Hey there! If I understand your question correctly, then I believe that this is all that you need to do:

script.Parent.Touched:Connect(function(e) -- Detects touch
    if e.Parent:FindFirstChild("Humanoid") then -- Checks to make sure a player touched it
        local gamepass = 12345678 --Change this to your gamepass ID
        local player = game.Players:FindFirstChild(e.Parent.Name)
        local service = game:GetService("MarketplaceService")
        if service:UserOwnsGamePassAsync(player.UserId,gamepass) then
            e.Parent.Humanoid.WalkSpeed = 100 -- Change this to the speed you want
        end
    end
end)

Hope this helps!

~Amanda314159

0
what is this supposed to do exactly? I put it in a part on workspace but nothing happened. Should I put it somewhere else? DudeHyper321 17 — 2y
0
If a player touches it and owns that gamepass, their speed will increase. Be sure to change "gamepass" on line 06 to the ID of your gamepass. If this isn't what you meant, then please explain further of what you are attempting to accomplish :) Amanda314159 291 — 2y
Ad

Answer this question