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

Anthro Mr grey I cant get it to animate when I press the F key?

Asked by 5 years ago

i have tried everthing to get this anthro to animate but nothing is working this is the script i have been using what am i doing wrong?

local Player = game.Players.LocalPlayer

local Character = Player.Character or script.Parent

local Humanoid = Character.Humanoid

local UserInputService = game.GetService("UserInputService")

local Animation = 'rbxassetid://03111119958'

local Key = 'G'

UserInputService.InputBegan:Connect(function(Input, IsTyping)

if IsTyping then return end

if Input.KeyCode == Enum.KeyCode[Key] then

local Animation = Instance.new("Animation")

Animation.AnimationId = AnimationId

local LoadAnimation = Humanoid:LoadAnimation(Animation)

LoadAnimation:Play

end

end)

2 answers

Log in to vote
1
Answered by 5 years ago

I think the script just isn't running because of wrong syntax in a few places.

  1. Write local Character = Player.Character, leaving out the "or script.Parent."
  2. You have game.GetService("UserInputService"); it should be game:GetService("UserInputService").
  3. You have LoadAnimation:Play; it should be LoadAnimation:Play().

If the script you wrote isn't working, run the game and look at "Output" (found under "View"). You'll find error messages printed out there.

Ad
Log in to vote
0
Answered by 5 years ago

I get the vibes of a free model but even then its full of mistakes. It should look more like

local hum = game:GetService("Players").LocalPlayer.Character:FindFirstChild("Humanoid")
local anim = Instance.new("Animation")
anim.Parent = script --- pretty sure can go without that
anim.AnimationId = "rbxassetid://03111119958" --- note out that this animation won't work unless you are the one to make it, also make sure that its the correct id

game:GetService("UserInputService"):Connect(function(i,gpe)
    if gpe == false and i.KeyCode == Enum.KeyCode.F then --- a thing that i saw in that code is that you are using "G" and not "F" even though the title says "F"
        hum:LoadAnimation(anim):Play()
    end
end)

Check this to learn about loading animations into the humanoid and how to play them

Check this to learn about InputBegan

Answer this question