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

Help on conditional?

I was making the sword shop. Then when I spammed the button. I went into the negative coins. I set up a conditional but it seemed to work.

if game.Players:FindFirstChild(player.Name).leaderstats.Coins.Value >= 2000 then --do stuff end

I am on mobile so this was from Memory. The coin subtraction is fine. Going into negatives isn't.

1 comment

0

There's nothing wrong with that line, as far as I can tell. Make sure everything that you meant to be is in "do stuff".

2 answers

✓ Accepted answer

I can't tell if this is the issue with only one line, but maybe you should try adding a debounce so they can't spam the button. There's probably some other issue, but I can't fix it with just that.

pressed = false

if game.Players:FindFirstChild(player.Name).leaderstats.Coins.Value >= 2000 and not pressed then
	-- Do stuff.
	wait(1)
	pressed = true
end

1 comment

0

I think you meant to put the pressed=true before the wait, and pressed=false after it.

Are you using a NumberValue? Sometimes if you keep adding to a number value it will just hit a certain point and go negative. I'd suggest using an IntValue ;o;

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