Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

So i am making a Double Sword, and i'm having trouble with making it damage?

Asked by 4 years ago

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)
0
why are you putting so many ~ aka not equal signs? VVoretex 146 — 4y
0
and put it all in a code block it's so hard to read sean_thecoolman 189 — 4y

1 answer

Log in to vote
0
Answered by
VVoretex 146
4 years ago

You should use the Humanoid:TakeDamage() function

https://developer.roblox.com/en-us/api-reference/function/Humanoid/TakeDamage

Ad

Answer this question