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

Purchasing Items after Rebirth?

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)

1 comment

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.

1 answer

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)

1 comment

0

Any update on how it went?

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