wait (1) local character = game.Players.LocalPlayer.Character character.Humanoid.Health = 1 local Message = Instance.new("BillboardGui",character) local text = Instance.new("TextLabel",Message) text.Text = "Life Leech" text.Size = UDim2.new({0, 200},{0, 50}) text.BackgroundTransparency = 1 text.TextScaled = true Message.Adornee = character.Head Message.StudsOffset = Vector3.new(0,1.5,0) text.TextColor3 = Color3.new(85,0,0) text.TextStrokeColor3 = Color3.new(255,0,0) text.TextStrokeTransparency = 0.4 --Sword local sword = Instance.new("Part",character) sword.Size = Vector3.new(1,5,1) local swordmesh = Instance.new("SpecialMesh",sword) swordmesh.TextureId = "http://www.roblox.com/asset/?id=262695937" swordmesh.MeshId = "http://www.roblox.com/asset/?id=130101214" swordmesh.Scale = Vector3.new(1,1,1) local weld = Instance.new("Weld",character) weld.Part1 = character["Right Arm"] weld.Part0 = sword weld.C0 = CFrame.new(0.1,-2.8,0) * CFrame.Angles(2,0,0) --Sword --Fightevent local Mouse = game.Players.LocalPlayer:GetMouse() Mouse.Button1Down:Connect(function() local p = character.Torso["Right Shoulder"] sword.Touched:connect(function(hit) local b = hit.Parent:FindFirstChild("Humanoid") if b ~= nil then b:TakeDamage(5) character.Humanoid.Health = character.Humanoid.Health + b.Health end end) for i = 1,10 do p.C1 = p.C1:lerp(p.C1 * CFrame.Angles(0,0,math.rad(45)),0.8) wait () end end) while true do character.Humanoid:TakeDamage(5) wait (2) end
The lines where damage happens is at the end and at line 41 Can you tell me why the player gets instantly killed instead of 5 health being taken away
Add a cooldown to sword.Touched. When you touch a sword it will give you damage but it calls everytime you touch it.
Make it like this:
local debounce = false sword.Touched:connect(function(hit) if debounce == false then debounce = true local b = hit.Parent:FindFirstChild("Humanoid") if b ~= nil then b:TakeDamage(5) character.Humanoid.Health = character.Humanoid.Health + b.Health wait(1) --cooldown here debounce = false end end)