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

How would you make a Key Animation?

Asked by 10 years ago

How would you create a script, that would not only play an animation, but would damage the player, when you press "e", or any simple key..

1 answer

Log in to vote
0
Answered by 10 years ago

Try this (might not work):

local Player = game:GetService("Players").LocalPlayer
local Character = Player:WaitForChild("Character")
local Humanoid = Character:WaitForChild("Humanoid")
local Mouse = Player:GetMouse()
local ID = 1337 --change to your animation id
local Animation = Instance.new("Animation", Player.Character)
Animation.AnimationId = ID

Mouse.KeyDown:connect(function(k)
    if k == "e" then
        Humanoid:LoadAnimation(Animation)
        Humanoid:TakeDamage(10) --change 10 to your amount
    end
end)
Ad

Answer this question