Issue when player purchases one item it purchases all

You can write your topic however you want, but you need to answer these questions:

  1. 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.

  1. 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)```

On the serverscript I noticed for your first if statement you have elseif, shouldn’t it be if? Additionally you shouldn’t check if the player has enough coins on the client, instead the server.

No the first statement is “if” i decided to remove it because it isn’t really relevant to the problem. However I will take note of coins on the client thing.

Everything is relevant my friend.

1 Like

Found the issue and fixed it has nothing to do eith the player buying anything.