I have a script setup that plays an animation and disables a damage script, it worked when I didn't have the damage script disabled being true and false
Animation Script:
local humanoid = game.Players.LocalPlayer.Character:WaitForChild('Humanoid') local right = script:WaitForChild('RightPunch') local left = script:WaitForChild('PunchLeft') local idle = script:WaitForChild('Idle') local kick = script:WaitForChild('Kick') local combo = script:WaitForChild('Combo') local enabled = false local Mouse = game.Players.LocalPlayer:GetMouse() local damScript = script.Parent:WaitForChild("PunchDamage")
Mouse.KeyDown:connect(function(key) if key == 'v' then local anim = humanoid:LoadAnimation(idle) if enabled == false then print('Ability Enabled') anim:Play() enabled = true elseif enabled == true then print('Ability Disabled') anim:Stop() enabled = false end end
if key == 'e'then
local anim = humanoid:LoadAnimation(right)
if enabled == true then
anim:Play()
damScript.Disabled = false
wait(0.5)
damScript.Disabled = true
else print('Ability Not Equipped')
end
elseif key == 'q' then
local anim = humanoid:LoadAnimation(left)
if enabled == true then
anim:Play()
damScript.Disabled = false
wait(0.5)
damScript.Disabled = true
else print('Ability Not Equipped')
end
elseif key == 'f' then
local anim = humanoid:LoadAnimation(kick)
if enabled == true then
anim:Play()
damScript.Disabled = false
wait(0.5)
damScript.Disabled = true
else print('Ability Not Equipped')
end
end
end)
Damage Script:
local char = script.Parent local rhand = char:WaitForChild("RightHand") local lhand = char:WaitForChild("LeftHand") local lfoot = char:WaitForChild("LeftFoot") function rHandTouched(partHit) local hum = partHit.Parent:FindFirstChildWhichIsA('Humanoid') if hum then wait(.1) hum:TakeDamage(10) end end
function lHandTouched(partHit) local hum = partHit.Parent:FindFirstChildWhichIsA('Humanoid') if hum then wait(.1) hum:TakeDamage(10) end end
function lFootTouched(partHit) local hum = partHit.Parent:FindFirstChildWhichIsA('Humanoid') if hum then wait(.1) hum:TakeDamage(15) end end
rhand.Touched:Connect(rHandTouched) lhand.Touched:Connect(lHandTouched) lfoot.Touched:Connect(lFootTouched)
The scripts are in startercharacter scripts

1 comment
How would you do your way? I just can't think of a way how.