Help with script issue

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!

Stop players from spamming textbutton within tool

  1. What is the issue? Include screenshots / videos if possible!

Players are equipping and re-equipping tool to override debounce

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve tried equipped; however, equipped is not a valid member of textbutton.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local name = 1
plr = game.Players.LocalPlayer
debounce = false
cooldown = 50

script.Parent.MouseButton1Click:Connect(function()
if name == 1 then
name = 2
if debounce == false then
game.ReplicatedStorage[“Almighty Push”]:FireServer()
wait(script.Parent.Parent.Parent.Value.Value)
debounce = true
wait(cooldown)
debounce = false
name = 1
end
end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Reformatted Code:

local name = 1
plr = game.Players.LocalPlayer
debounce = false
cooldown = 50

script.Parent.MouseButton1Click:Connect(function()
	if name == 1 then
		name = 2
		if debounce == false then
			game.ReplicatedStorage[“Almighty Push”]:FireServer()
			wait(script.Parent.Parent.Parent.Value.Value)
			debounce = true
			wait(cooldown)
			debounce = false
			name = 1
		end
	end
end)

May I ask what the name variable is supposed to be, and what it does? And also, what exactly is this script supposed to do for players?

And also, you should make debounce and cooldown a global variable.

This might be a stupid question, but why would cooldown need to be global?
And rather then using a global variable, wouldn’t using a boolValue located inside the tool (or where ever else you want because the tool changes ancestry) be better? (idk i’ve always been told Global variables are bad. idk if theres any more reason then just taking up variable names tho)

1 Like

Sorry, I’m extremely tired because It’s pasted my usual bedtime.

I meant to write that he should be using a local variable instead of a global variable.

I’m not exactly sure what this tool this is that the OP is referring to.

1 Like