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

How to touch part upon gamepass purchase?

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

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

2 comments

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?

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 :)

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