Why wont this script for my tool work?

I want this tool to not be able to fire if one of the 3 attributes is currently true (attacking, blocking, stunned) but it doesn’t work. Can anybody help me fix it?
This is the local script

local uis= game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
plr.CharacterAdded:Wait()
local remote = game.ReplicatedStorage:WaitForChild("Abilities").Events.kneeevent
local animation = game.ReplicatedStorage.Abilities.Anims.knee
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local debounce = false
local cd = 5
local tool = script.Parent
local stunned = char:GetAttribute("Stunned")
local stun = false
local blocking = char:GetAttribute("Blocking")
local block = false
local attacking = char:GetAttribute("Attacking")
local attack = false

while task.wait() do
	if stunned == true then
		stun = true
	else
		stun = false
	end
	if blocking == true then
		block = true
	else
		block = false
	end
	if attacking == true then
		attack = true
	else
		attack = false
	end
end



tool.Activated:Connect(function()
	if attack or stun or block then return end
		if not debounce then
			debounce = true
			local track = hum:LoadAnimation(animation)
			track:Play()
			remote:FireServer()
			wait(cd)
			debounce = false
		end
end)


You’re only getting the attributes’ values once, so the variables won’t change when the attribute changes. You should use GetAttributeChangedSignal instead.

I can get you a working example script, but I’m on my phone right now and don’t wanna type that all out on such a small keyboard.

Thanks, I managed to get it working

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.