local UserInPut = game:GetService("UserInputService")
local Money = game.Players.LocalPlayer:WaitForChild('leaderstats').Money
local anim = script.Animation
function AnimationPlay()
UserInPut.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E then
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild('Humanoid')
local Anim = humanoid:LoadAnimation(anim)
Money.Value += 1
Anim:Play()
end
end)
end
AnimationPlay()```there
#Animation
3 messages · Page 1 of 1 (latest)
this will break once the humanoid:LoadAnimation() limit is hit
The issue is that you're trying to load the animation before the character is loaded
You need to update the p (the animationtrack from humanoid:LoadAnimation) every time the player makes a new character.
I recommend doing some pattern like:
local moneyGainedAnimationTrack
local function onCharacterAdded(character: Model)
-- get humanoid
moneyGainedAnimationTrack = humanoid:LoadAnimation(anim)
end
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
end