Here is the script its not the best but it my try at it im kinda in experienced
This is my full script i tried my best
local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?id=873178948" Player = game.Players.LocalPlayer mouse = Player:GetMouse() local Player = game.Players.LocalPlayer local Character = Player.Character local Humanoid = Character:WaitForChild("Humanoid") local Animation = Instance.new("Animation") function Hit(damage) if damage.Parent:FindFirstChild("Humanoid") and damage.Parent.Name ~= Player.Name then damage.Parent.Humanoid.Health = damage.Parent.Humanoid.Health -1 end end local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local animTrack = nil local CanDamage = true local CanDamage = false CanDamage = false Mouse.KeyDown:connect(function(key) if key:lower() == "q" then local character = Player.Character animTrack = character:WaitForChild("Humanoid"):LoadAnimation(animation) animTrack:Play() Player.Character["Left Arm"].Touched:connect(Hit) local CanDamage = false end end)
Hello,
I have tried to help as far as I can because your script is a mess.
Localscript found in Backpack :
local animation = Instance.new("Animation") animation.AnimationId = "rbxassetid://873178948" --Convert it into an assetid by putting it into a AnimationId slot. local player = game.Players.LocalPlayer local mouse = player:GetMouse() --local Character = Player.Character -- In studio , everything loads nearly instantly, but on servers there is a delay. repeat wait() until player.Character -- This creates a loop until the player has fully loaded. local char = player.Character local hum = char:findFirstChild("Humanoid") local animTrack = nil local CanDamage = true -- Why do you declare both as false and true? --The above is a debounce , which prevents the instant death of a Humanoid. mouse.KeyDown:connect(function(key) if key:lower() == "q" then --animTrack = char:WaitForChild("Humanoid"):LoadAnimation(animation) --animTrack:Play() char["Left Arm"].Touched:Connect(function(hit) if (hit.Parent:FindFirstChild("Humanoid")) and (hit.Parent.Name ~= player.Name) and (CanDamage == true) then --hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health -1 -- Too much effort. hit.Parent:findFirstChild("Humanoid"):TakeDamage(1) -- This is the line that damages the Humanoid. --If that was what you were searching for. CanDamage = false wait(1) CanDamage = true end end) end end)
I am still learning RbxLua.
Thank you for reading.