My Code for the animation player - l~~~~~~~~~~~~~~~~~ ocal CanDamage = script.Parent.Parent.Values.CanDamage local SoundPlayed = script.Parent.Parent.Values.SoundPlayed
function reRoll()
local randomPick = math.random(1, #exTable) local exValue = exTable[randomPick] return exValue end
tool.Activated:Connect(function() CanDamage.Value = true if debounceTrue == false then debounceTrue = true local exValue = reRoll() if exValue ~= lastValue then lastValue = exValue local Animation = Instance.new("Animation") Animation.AnimationId = "rbxassetid://"..exValue local animTrack = humanoid:LoadAnimation(Animation) animTrack:Play() wait(debounceTime) debounceTrue = false elseif exValue == lastValue then print("[ERROR] "..exValue.." was already rolled. Rerolling.") repeat exValue = reRoll() until exValue ~= lastValue lastValue = exValue local Animation = Instance.new("Animation") Animation.AnimationId = "rbxassetid://"..exValue SoundPlayed.Value = true local animTrack = humanoid:LoadAnimation(Animation) animTrack:Play() wait(debounceTime) debounceTrue = false end end end)
The code for the damager - l~~~~~~~~~~~~~~~~~ ocal CanDamage = script.Parent.Parent:WaitForChild("Values").CanDamage local Check = true local Damage = script.Parent.Parent.Values.Damage local Blade1 = script.Parent.Parent.Union local Blade2 = script.Parent.Parent.Union2 local Blades = Blade1 or Blade2 Blades.Touched:Connect(function(t) local Humanoid = t.Parent:FindFirstChild("Humanoid") if Check == true and Humanoid then if CanDamage.Value == true then CanDamage.Value = false Check = false Humanoid.Health = Humanoid.Health - Damage.Value wait(0.1) Check = true end end end)
You should use the Humanoid:TakeDamage() function
https://developer.roblox.com/en-us/api-reference/function/Humanoid/TakeDamage