hey, so i made a sword , and a dummy (to test damage), the problem is, that it takes sooo much time for the dummy to get hit, so i want to improve it and make the dummy always get hit when it suppose to…
here’s what i mean:
https://gyazo.com/138567e81894bd4f6d513f3723484de2
here is the scripts and the locatios of all:
the dummy:
DamageEncounter Script:
local humanoid = script.Parent
local cHealth = humanoid.Health
humanoid.HealthChanged:Connect(function(health)
local Gui = script.DamageCounter:Clone()
local change = math.floor(cHealth - health)
if change == 0 then return end
Gui.Parent = humanoid.Parent.Head
Gui.TextLabel.Text = change
humanoid.Health = humanoid.MaxHealth
wait(1)
for i = 0,1, .1 do
Gui.TextLabel.TextTransparency = i
Gui.TextLabel.TextStrokeTransparency = i
wait()
end
end)
the sword:
sword script:
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://3493431823"
local trail = script.Parent.Handle.Trail
local animTrack
local tool = script.Parent
local char
local debounce = false
tool.Activated:Connect(function()
if not debounce then
debounce = true
local char = tool.Parent
animTrack = char.Humanoid:LoadAnimation(animation)
trail.Enabled = true
animTrack:Play()
local dmg = script.Damage:Clone()
dmg.Parent = tool.blade
dmg.Disabled = false
wait(animTrack.Length)
if dmg then
dmg:Destroy()
end
trail.Enabled = false
wait(1)
debounce = false
end
end)
tool.Unequipped:Connect(function()
if animTrack then
animTrack:Stop()
end
end)
damage inside the sword script:
local weapon = script.Parent
local dmg = 5
weapon.Touched:connect(function(part)
if part.Parent:findFirstChild("Humanoid") then
local humanoid = part.Parent:findFirstChild("Humanoid")
humanoid:TakeDamage(dmg)
script:Destroy()
end
end)
and that’s all, thanks in advance