I'm making an attack that plays an animation and in the animation the player damages whatever player that touches the damage radius that is already in the player. The first script normally works correctly except for when I add the part to activate the script that is in the radius that allows it to do damage. The damage script is already disabled but doesn't work on it's own when its enabled. Any help would be greatly appreciated.
Script playing animation and enabling damage.
--Finds Player-- local UserInputService = game:GetService("UserInputService") local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:wait() local Humanoid = Character:WaitForChild("Humanoid") local BlastDamage = Character:WaitForChild("Blast"):WaitForChild("Script") --Finds Animations-- local Animation = Instance.new("Animation") Animation.AnimationId = "rbxassetid://2867339187" local AnimationR = Instance.new("Animation") AnimationR.AnimationId = "rbxassetid://2867339668" local AnimationL = Instance.new("Animation") AnimationL.AnimationId = "rbxassetid://2867395453" local Animations = {AnimationL,AnimationR} local track = Humanoid:LoadAnimation(Animation) local CanDamage = false --Just finding the Particles-- local particle = Character:WaitForChild("LeftUpperArm"):WaitForChild("ParticleEmitter") local particle1 = Character:WaitForChild("RightLowerArm"):WaitForChild("ParticleEmitter") local particle2 = Character:WaitForChild("RightUpperLeg"):WaitForChild("ParticleEmitter") local particle3 = Character:WaitForChild("UpperTorso"):WaitForChild("ParticleEmitter") local particle4 = Character:WaitForChild("LowerTorso"):WaitForChild("ParticleEmitter") --Funtion That Starts Animation and Enables the Particles-- UserInputService.InputBegan:Connect(function(input, proc) local track2 = Humanoid:LoadAnimation(Animations[math.random(#Animations)]) if not proc and input.KeyCode == Enum.KeyCode.T then CanDamage = false particle.Enabled = true particle1.Enabled = true particle2.Enabled = true particle3.Enabled = true particle4.Enabled = true track:Play() wait(0.35) track:Stop() track2:Play() --Animaton Follows-- wait(0.45) track2:Stop() particle.Enabled = false particle1.Enabled = false particle2.Enabled = false particle3.Enabled = false particle4.Enabled = false CanDamage = true end --Enables BlastDamage Script-- if CanDamage == true then BlastDamage.Disabled = false wait(0.1) BlastDamage.Disabled = true end wait(0.00000001) CanDamage = false end)
Damage Script.
local CanDamage = false --Damage Function-- function OnTouched(Part) if Part.Parent ~= nil then if CanDamage == false and Part.Parent:findFirstChild("Humanoid") ~= nil then CanDamage = true Part.Parent:findFirstChild("Humanoid"):TakeDamage(50) wait(2) CanDamage = false end end end --Plays Function When Blast is touched-- script.Parent.Touched:Connect(OnTouched)