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

HELP HELP URGENT CAN SOMEONE HELP ME? [closed]

Asked by 7 years ago

I NEED THIS DONE BY TOMMOROW BUT I DON'T KNOW HOW TO DO IT

wait(2)

local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
Anim = script.Animation

Mouse.KeyDown:connect(function(key)
if key == "e" then
s = player.Character.Humanoid:LoadAnimation(Anim)
s:Play()
end
end)

HELP WOULD REALLY BE APPRECIATED

0
Thanks man Thisnoguest 27 — 7y

Closed as Not Constructive by evaera

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
funzrey 58
7 years ago
Edited 7 years ago

So your animation code works fine, but it seems to be that you are using Mouse.KeyDown [deprecated] instead of a newer function. Let me help you on this code.

--EDIT: Defined variables
wait(2)

local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
Anim = script.Animation

--First we create the function for the key press
function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        s = player.Character.Humanoid:LoadAnimation(Anim)
        s:Play()
    end
end

--Then we bind it.
game.ContextActionService:BindAction("keyPress", onKeyPress, false, "e")

What this basically does is that it makes use of ContextActionService which is a useful service for a lot of things, and binds a keypress action checking for the key "e" which is the key you demonstrated above, then it runs the animation code. Remember to put this in a localscript, and lua on!

Ad