Let's start out by tabbing your code correctly:
wait(2)
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local humanoid = player.Character.Humanoid
local s = humanoid:LoadAnimation(game.StarterPack.RoundHouse.Animation)
Mouse.KeyDown:connect(function(key)
if key:lower() == "f" and humanoid then
s:Play()
game.Players.Character.Humanoid.Health = -20
wait(5)
end
end)
Let's now read all of my annotations, explaining what your script does in list form:
Wait 2 seconds
Get the LocalPlayer
Get the Mouse
Get the Humanoid
Load animation into Humanoid to be used as a variable
When they press a key
If that key is f and the humanoid is not nil
Play the roundhouse kick animation
Set the LocalPlayer's health to -20
Wait 5 seconds
Done
I think you can see the problem from this now. In order to make the Kick do damage, you need to do a connection function for if LocalPlayer hits the other. If he does hit the player, do damage.
game.Players.Character.Humanoid.Health = -20
game.Players.Character.Humanoid.Health = game.Players.Character.Humanoid.Health - 20
game.Players.Character.Humanoid:TakeDamage(20)
1 comment
Thanks but how do I do a connection function? I'm new at scripting. I only know basics.