Now i know why this doesen't work and it says newAnim is a nil value even though its a global variable?
local p = game.Players.LocalPlayer
local anim = script.Animation
local serv = game:GetService("UserInputService")
local keyCodeQ = Enum.KeyCode.Q
local keyCodeE = Enum.KeyCode.E
local char = p.Character -- their character
if not p.Character then -- checks to see if the character exists
repeat wait() until p.Character -- if not, it waits until it exists
end
local human = char:WaitForChild("Humanoid") -- the character's humanoid (required to load an animation)
serv.InputBegan:connect(function(key,processed)
if serv:IsKeyDown(keyCodeQ) and serv:IsKeyDown(keyCodeE) then -- change 'F' to your key, also checks to see if a player is typing (etc.) or not
print("Starting animation!")
newAnim = human:LoadAnimation(anim)
newAnim:Play()
end
end)
serv.InputEnded:connect(function(input)
if not serv:IsKeyDown(keyCodeQ) and not serv:IsKeyDown(keyCodeE) then
newAnim:Stop()
end
end)
