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

Why my BoolValue changer on my script is not working?

Why the IsAttacking BoolValue's Value doesn't change?

Tool = script.Parent
Damage = script.Parent.Settings.Damage
local ButtonPressed = false
Attacking = script.Parent.Scripts.IsAttacking

Tool.Equipped:connect(function(Mouse)
	Mouse.Button1Down:connect(function()
----------------------------------------------------------------------	
		script.Parent.DamagePart.Touched:connect(function(hit)
			if not ButtonPressed then
				--is it not pressed?
				ButtonPressed = true
				Attacking.Value = true -- here
				--
				--
				if hit.Parent then
				local human = hit.Parent
				hum = human:FindFirstChild("Humanoid")
				if hum then
					hum.Health = hum.Health - script.Parent.Settings.Damage.Value
				else
					print("Humanoid Not Found")
				end
				wait(1)
				end
				--
				Attacking.Value = false -- here
				ButtonPressed = false
			end
		end)
---------------------------------------------------------------------
	end)
end)

2 answers

That's because your Bool Value immediately sets to True whenever the Touched event fires, so it never changes.

Perhaps add a wait() before setting IsAttacking to false

Use a direct boolean instead of one located in the Workspace, like:

bool = true

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