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

Help with a gamepass prompt showing up for everyone when a player touches a block. Any solutions?

local mps = game:GetService("MarketplaceService")
local gamepass_id = 18476957
local pad = game.workspace.ProductStands.Horse.ColoredParts.TouchMe


pad.touched:Connect(function(player)
	local player = game.Players.LocalPlayer
	mps:PromptGamePassPurchase(player, gamepass_id)
end)

mps.PromptGamePassPurchaseFinished:Connect(function(player, id, purchased)
	if id == gamepass_id and purchased then
		game.ReplicatedStorage.GiveHorse:FireServer()
	end
end)

This is a localscript in starterplayerscripts

1 answer

✓ Accepted answer

Greetings!

According to your script, if anyone, no matter who it is, touches the pad object, it will show up a gamepass prompt. A fairly easy fix to this is to check who touched the pad, and check if it is you or not.

pad.Touched:Connect(function(part)
	local player = game.Players.LocalPlayer
	if part:IsDescendantOf(player.Character) then --checks if the part that touched the pad is from your character
		mps:PromptGamePassPurchase(player, gamepass_id)
	end
end)

If you're confused, I can answer some of your questions.

I hope this helps!

3 comments

0

Thanks for the kind help! One question, do I replace this with my script from pad.touched to end?

0

Er, no, you only replace from pad.Touched to end)

0

Ok, cool

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