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

Purchasing Items after Rebirth?

Asked by
Zelt3q 31
3 years ago

I'm having some issues finding out how to let people purchase the same item after they have purchased. Any Suggestions?

ReplicatedStorage.ShopEvents.Ninjago.OnServerEvent:Connect(function(player)
    if player.leaderstats.Money.Value >= 500 and MyDebounce == true and player then
        MyDebounce = false
        player.leaderstats.Money.Value = player.leaderstats.Money.Value - 500

        ServerStorage.Tools.AzureSword:Clone().Parent = player.Backpack
        game.StarterGui.Shop.Shop.BuyingInfo.LegoNinjago.Buy.Text = "Bought"

        if player.leaderstats.Rebirths.Value >= player.leaderstats.Rebirths.Value + 1 and MyDebounce == false and player then
            MyDebounce = true

        end
    end
end)
0
Please give a clarification on this question. Do you mean they don't have to spend money on it after they rebirthed? I am confused. Nckripted 580 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

I believe your MyDebounce never reverts to true. In this case, it only is able to run it once since the dbounce never reverts back to true and it's required to be true for the function to run.

Also, since the MyDebounce doesn't seem to be local in the function, if one player fires the event, the MyDebounce will change for all players. You want to make the MyDebounce local to the function.

local MyDebounce = true then put the rest of your script

ReplicatedStorage.ShopEvents.Ninjago.OnServerEvent:Connect(function(player)
local MyDebounce = true 
    if player.leaderstats.Money.Value >= 500 and MyDebounce == true and player then
        MyDebounce = false
        player.leaderstats.Money.Value = player.leaderstats.Money.Value - 500

        ServerStorage.Tools.AzureSword:Clone().Parent = player.Backpack
        game.StarterGui.Shop.Shop.BuyingInfo.LegoNinjago.Buy.Text = "Bought"

        if player.leaderstats.Rebirths.Value >= player.leaderstats.Rebirths.Value + 1 and MyDebounce == false and player then
            MyDebounce = true

        end
    end
end)
0
Any update on how it went? DevMaster333 215 — 3y
Ad

Answer this question