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

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

Asked by
xp5u 25
3 years ago
Edited 3 years ago
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

Log in to vote
0
Answered by
RAFA1608 543 Moderation Voter
3 years ago

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!

0
Thanks for the kind help! One question, do I replace this with my script from pad.touched to end? xp5u 25 — 3y
0
Er, no, you only replace from pad.Touched to end) RAFA1608 543 — 3y
0
Ok, cool xp5u 25 — 3y
Ad

Answer this question