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

tool script not working?

ok so i have a tool script and when i click it once it calls the fire function but when i click it again it doesnt work.

local players = game.Players
local tool = script.Parent
repeat wait() until players.LocalPlayer and players.LocalPlayer.Character
local player = players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local debounce = false


tool.Activated:connect(function()
	if debounce then return end
	debounce = true
	local vote = Instance.new("Hint",game.Workspace)
	vote.Text = player.Name.. " has voted"
	game.Debris:AddItem(vote,5)
end)


1 answer

✓ Accepted answer

Ok, your problem is that you forgot to set your debounce back to false after you clicked, since it stayed to true it would not execute the rest of your code. Remember to always check your debounces.

local players = game.Players
local tool = script.Parent
repeat wait() until players.LocalPlayer and players.LocalPlayer.Character
local player = players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local debounce = false


tool.Activated:connect(function()
    if debounce then return end
    debounce = true
    local vote = Instance.new("Hint",game.Workspace)
    vote.Text = player.Name.. " has voted"
    game.Debris:AddItem(vote,5)
    debounce = false -- You need to set your debounce back to false again
end)

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