i have a big live event for my game, and i wanna destroy the teleporter part if the player buys a gamepass, but not for everyone, only for the buyer of the gamepass.
script:
local mps = game:GetService("MarketplaceService")
local event = game.ReplicatedStorage.Remotes.SkipObby
local gamepass_ID = 872455840
mps:GetProductInfo(gamepass_ID, Enum.InfoType.GamePass)
mps.PromptGamePassPurchaseFinished:Connect(function(plr, IsPurchased:boolean)
if IsPurchased then
print(plr.Name.." purchased the gamepass with Product ID: "..gamepass_ID)
event:FireClient(plr)
workspace:WaitForChild("Teleporter"):Destroy()
end
end)
1 Like
If the handling of the PromptGamePassPurchaseFinished
event is done on the server, then you should move the workspace:WaitForChild("Teleporter"):Destroy()
part to the LocalScript
where you are listening for the RemoteEvent
or else everyone in the server would see the Teleporter gone.
Also, since this is a gamepass you might want to ensure everyone who bought the gamepass and rejoined that the effect they bought the gamepass for is still there using the UserOwnsGamePassAsync event.
2 Likes
Add an additional check for checking if the user actually owns the gamepass or not with the UserOwnsGamePassAsync
Back in April, I developed a script for exploiters to use to hunt vulnerabilities in games with free UGC in it and called it Wyvern, it was a protest for “Free UGC should be free! It shouldn’t be behind a paywall or stupidly absurd game quests!” One of it’s features was tricking the RCC (Roblox’s Game Server) into thinking a GamePass or a DevProduct was purchased by getting the signal to fire without actually buying the product. This is done by calling the SignalPromptGamePassPurchaseFinished function which is called by CoreScripts to signal to the server that a purchase was successful. Since exploiters can’t hook functions at the server side, you should be good with double checking if the user owns the gamepass with UserOwnsGamePassAsync.
2 Likes
but how to make the effect tho?
1 Like
will this script work? server sided script btw:
local mps = game:GetService("MarketplaceService")
local event = game.ReplicatedStorage.Remotes.SkipObby
local gamepass_ID = 872455840
mps:GetProductInfo(gamepass_ID, Enum.InfoType.GamePass)
mps.PromptGamePassPurchaseFinished:Connect(function(plr, IsPurchased:boolean)
if IsPurchased then
print(plr.Name.." purchased the gamepass with Product ID: "..gamepass_ID)
game.Players.PlayerAdded:Connect(function(plr)
if mps:UserOwnsGamePassAsync(plr.UserId, gamepass_ID) then
event:FireClient(plr)
workspace.Teleporter:Destroy()
end
end)
end
end)
keep in mind that the result of this is cached; the result is only computed once until the player rejoins the server which is why old games tended to prompt you to rejoin to apply gamepasses