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

Skip stage button on obby increases stage value but doesn't tp me to stage spawn point?

Asked by 4 years ago

Here's the script for the dev product: ~~~~~~~~~~~~~~~~~ local productId = 915594981 local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(player, productId) end)


Here's the things to skip the stage:~~~~~~~~~~~~~~~~~ MarketplaceService = game:GetService("MarketplaceService") MarketplaceService.ProcessReceipt = function(receiptInfo) players = game.Players:GetPlayers() currency = "Stage" done = 0 for i=1,#players do if players[i].userId == receiptInfo.PlayerId then if receiptInfo.ProductId == 915594981 and done == 0 then done = 1 players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 1 players[i].Character.Humanoid.Health = 0 done = 0 end end end return Enum.ProductPurchaseDecision.PurchaseGranted end

Whenever I buy the product, it increases my stage value, but it won't teleport me to the spawn point of that stage.

0
srry first time posting didnt understand the code block feature blade2reaper 0 — 4y
0
Why obbies.. It's just like a virus lol Unscriptablee 20 — 4y

1 answer

Log in to vote
3
Answered by
appxritixn 2235 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

I don't see you teleporting the player anywhere in your script.

What I see you trying to do is set the stage to [current+1], and then killing the player, which is not an extremely effective way of doing it. Personally, I would alter the player's CFrame like so..

MarketplaceService = game:GetService("MarketplaceService")

MarketplaceService.ProcessReceipt = function(receiptInfo)
players = game.Players:GetPlayers()

currency = "Stage"

done = 0

for i=1,#players do
    if players[i].userId == receiptInfo.PlayerId then
        if receiptInfo.ProductId == 915594981 and done == 0 then
            done = 1
            players[i].leaderstats[currency].Value = players[i].leaderstats[currency].Value + 1
            game.Workspace[players[i].Name]:WaitForChild("HumanoidRootPart").CFrame = CFrame.new([Spawn Position] + Vector3.new(0,3,0))
            done = 0
        end
    end
end
return Enum.ProductPurchaseDecision.PurchaseGranted 
end

Of course, change [Spawn Position] on line 15 to the position of the stages spawn point.

The change made is on line 15. I took out you killing the player, and teleported them to the spawn point instead.

1
You may have to view source code to see all of the code on line 15. appxritixn 2235 — 4y
0
It did not teleport to the spawn point. I replaced [Spawn Position] with the coords of the spawn point. blade2reaper 0 — 4y
1
Does it do anything? appxritixn 2235 — 4y
0
It doesn't even increase stage number blade2reaper 0 — 4y
1
That does not make much sense. I only changed line 15, and from what I can tell, it should not affect line 14 at all, unless an error is thrown which you have not said is the case. appxritixn 2235 — 4y
Ad

Answer this question