Basically, i want a button to be pressed, then through that button, a remote event is fired. The problem is that it sends the remote event many times even though i only pressed the button once. I have tried using debounce but it doesn't work
here is the code:
b1button.MouseButton1Down:Connect(function()
if Cash >= DC1price then
if buttonpressed == false then
buttonpressed = true
Cash = Cash - DC1price
print("item bought")
confirm.Visible = false
item1:FireServer(1)
buttonpressed = false
end
end
end)
this is with debounce.
Also there is a strange pattern in the output, first it sends one remote event, then when i press it again it sends 2, then 3, then 4, ect So the outputt shows:
item bought (*1)
then next time the number adds:
item bought(*3)
and again
item bought(*6)
Anyone see any problem?
Thanks :)
edit: Someone asked for the server script, I don't think it has anything to do with it, since it is just recieving the remote event. The problem is that the item bought output from the "print item bought" is being printed several times every time i press the button, and the remote event being fired is just the result. but here is the server script anyways:
item1.OnServerEvent:Connect(function(Player, amount)
Player.itemcounter.DC1.Value = Player.itemcounter.DC1.Value + amount
end)

3 comments
can you show the server script too?
you only showed me the local script. It could be the server script's problem too
i edited it