You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want to make so when a player buys a “power up” it adds it to the table.
- What is the issue? Include screenshots / videos if possible!
When one item is bought all 4 of them are bought at once. As is all the events are fired at once which is impossible because i have added in the required debounces.
Side note: I only really learned about how to use module scripts properly today so please excuse i gues what you wold call “bad practice” and also ignore the fact there is no “if” statement i just cut it out.
Server Script:
event.OnServerEvent:Connect(function(plr, data, key, num)
print(data, key)
elseif key == "DoubleBlock" then
table.insert(PlayerBlockData, data)
MovesBought[data] = true
event:FireClient(plr, PlayerTimes, PlayerBlockData, ColorsBought, TexturesBought, MovesBought)
elseif key == "DoubleSize" then
table.insert(PlayerBlockData, data)
MovesBought[data] = true
event:FireClient(plr, PlayerTimes, PlayerBlockData, ColorsBought, TexturesBought, MovesBought)
elseif key == "MyBlock" then
table.insert(PlayerBlockData, data)
MovesBought[data] = true
event:FireClient(plr, PlayerTimes, PlayerBlockData, ColorsBought, TexturesBought, MovesBought)
elseif key == "AutoPlacing" then
table.insert(PlayerBlockData, data)
MovesBought[data] = true
print(MovesBought)
print(PlayerBlockData)
event:FireClient(plr, PlayerTimes, PlayerBlockData, ColorsBought, TexturesBought, MovesBought)
end
end)
An example of one of the local scripts:
confirmation.Yes.MouseButton1Up:Connect(function()
local plrcoins = plr.leaderstats.Coins
if plrcoins.Value >= tonumber(price) and clicked == true then
event:FireServer(TEXT, key)
confirmation.Visible = false
changeprop:FireServer(nil, key, part)
print(price)
purchaseevent:FireServer(price)
print(price.."afer")
else
print("not enough coins")
end
end)```