So I have created an animation script to go for my group and once you press "F" you "Pay Respects" but this only works in studio and not in-game. Is there something im doing wrong?
local animations = {
--Add your animations here like this format
[Enum.KeyCode.F] = 1254949146,--Plays when "K" is pressed
[Enum.KeyCode.L] = 216113394,--Plays when "L" is pressed
}
repeat wait() until game.Players.LocalPlayer.Character; local player = game.Players.LocalPlayer
repeat wait() until player.Character; local character = player.Character
local currentAnimId,currentPlaying = '',nil
local humanoid = character:FindFirstChild('Humanoid')
local uis = game:GetService('UserInputService')
uis.InputBegan:connect(function(input,gpe)
if not gpe then
if animations[input.KeyCode] ~= nil then
local animId = 'http://www.roblox.com/Asset?ID=' .. animations[input.KeyCode]
if animId ~= currentAnimId then
if humanoid ~= nil and humanoid.Health > 0 then
if currentPlaying ~= nil and currentPlaying.IsPlaying then
currentPlaying:Stop()
end
local animation = Instance.new('Animation'); animation.AnimationId = animId
local animTrack = humanoid:LoadAnimation(animation); currentPlaying = animTrack
animTrack:Play(0.100000001,1,1)
end
end
end
end
end)

3 comments
is your local script underneath the starterscripts for the player or somewhere else? local scripts will only work under starter scripts unless you are in studio which could be the problem.
I have it under StarterPack as a LocalScript
U have Filtering enabled? if so you need to load it using a server script