So i have this script in a tool if you press "r" it plays a sound and increases a Intvalue by 5 Though it doesn't play the animation and the animation is made by me its inside of the tool's handle. This is a local script. Everything except the animation works. This is a screenshot of the tool in explorer here
local shaking = false local flickering = false local maxcharge = script.Charge.Value local on = false function turnon() on = true script.Parent.Light.Enabled = true script.Parent.OnSound:Play() end function turnoff() on = false script.Parent.Light.Enabled = false end function click() if on ~= true and script.Charge.Value > 0 then turnon() else turnoff() end end script.Parent.Parent.Activated:connect(click) function flicker(tim) if flickering == false then flickering = true for i = 1, math.abs(math.random(-16, -tim)) do if script.Charge.Value > 1 and on == true then wait(math.abs(math.random(-30, -tim)) / 1000) if script.Parent.Light.Enabled == true then script.Parent.Light.Enabled = false else script.Parent.Light.Enabled = true end else turnoff() end end if script.Charge.Value > 0 and on == true then script.Parent.Light.Enabled = true end flickering = false end end local keyConnection = nil function onKeyDown(key) if key:lower() == "r" and shaking ~= true then vChar = script.Parent.Parent.Parent if vChar == nil then return end hum = vChar:FindFirstChild("Humanoid") if hum == nil then return end --if not Tool.Enabled then return end script.Parent.Parent.Enabled = false torso = vChar:FindFirstChild("Torso") if torso == nil then script.Parent.Parent.Enabled = true return end local shakeanim = hum:LoadAnimation(script.Parent.ShakeAnim) if shakeanim == nil then script.Parent.Parent.Enabled = true return end if shakeanim ~= nil then shaking = true shakeanim:Play() --This part doesn't work script.Parent.ShakeSound:Play() wait(0.15) shakeanim:Stop() --And this one if script.Charge.Value + 5 < maxcharge then script.Charge.Value = script.Charge.Value + 5 end shaking = false script.Parent.Parent.Enabled = true end end end function onEquippedLocal(mouse) keyConnection = mouse.KeyDown:connect(onKeyDown) end script.Parent.Parent.Equipped:connect(onEquippedLocal) while true do wait(0.25) if on == true and script.Charge.Value > 0 then script.Charge.Value = script.Charge.Value - 1 if script.Charge.Value < 15 and math.random(1, 10) < 5 then flicker(script.Charge.Value) end elseif script.Parent.Light.Enabled == true then turnoff() end end --script.Parent.Parent.Activated:connect(onActivate) --script.Parent.Light.Enabled.Changed:connect(cd)