Hey everybody… I’ve had this problem now for a day and no matter what I do or think up of I can’t figure out why this won’t work properly…
What do you want to achieve? I simply want an idle animation to play once a player equips a weapon (currently only one weapon named “Fists”).
What is the issue? Whenever I equip the weapon while playtesting in studio, the idle animation will play perfectly fine. However, after publishing and going into the game from Roblox, no idle animation will play when I equip my “Fists” weapon. No errors are displayed in the developer log in either studio or Roblox.
Here’s a short video of the animation playing properly in studio (you can tell it’s studio cause I didn’t crop it well):
And here’s a clip of me going into the game not on studio:
- What solutions have you tried so far? I have checked the scripts that I use for animations, both on the server and client sides. I’m always sure to have the most recent version of the game published when trying to test if I fix the bug in the actual game. My animations are uploaded onto my group which the game that I’m working on is also under. I’ve set the priority for my animation to “Idle” and have also re-uploaded it in a hopeless attempt of trying to fix this… (As far as I know, I haven’t seen anybody have a similar problem, it’s just forgetting to upload the animation to the proper place…)
Here’s the code that I use on the client side (forgive me if it’s any bit hard to read):
local ReplicatedStorage = game:GetService("ReplicatedStorage") local eventFolder = ReplicatedStorage:WaitForChild("Events") local animEntityEvent = eventFolder:WaitForChild("AnimateEntity") local function setAnimation(entity, animFolder, animName) local humanoid = entity:WaitForChild("Humanoid") if humanoid and animFolder then local animation = animFolder:FindFirstChild(animName) if animation ~= nil then local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid) local playingTracks = animator:GetPlayingAnimationTracks() for i, track in ipairs(playingTracks) do if track.Name == animName then return track end end local animationTrack = animator:LoadAnimation(animation) return animationTrack end else warn("animation for "..entity.." broke!") return false end end local function stopAnimation(entity, animName) local humanoid = entity:WaitForChild("Humanoid") if humanoid then local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid) local playingTracks = animator:GetPlayingAnimationTracks() for i, track in ipairs(playingTracks) do if track.Name == animName then track:Stop() end end else warn("error stopping animation for "..entity.."!") end end local function playAnim(entity, animFolder, animName) local animTrack = false if animFolder[animName]:IsA("Folder") then animFolder = animFolder[animName] animName = "main"..math.random(1, #animFolder:GetChildren()) animTrack = setAnimation(entity, animFolder, animName) else animTrack = setAnimation(entity, animFolder, animName) end if animTrack ~= false then animTrack:Play() else warn("animation broke lol") end end game.Workspace.Enemies.ChildAdded:Connect(function(entity) if entity:IsA("Model") then local animFolder = entity:FindFirstChild("Animations") if animFolder then playAnim(entity, animFolder, "move", true) else warn("no animations folder found for entity "..entity.Name) end end end) animEntityEvent.OnClientEvent:Connect(function(entity, animFolder, name, playOrStop) if playOrStop == true then --play animation playAnim(entity, animFolder, name) print(name) elseif playOrStop == false then --stop animation stopAnimation(entity, name) else --invalid value warn("invalid value given to player, check value being passed: "..playOrStop) end end)
The weird thing about all this is, if replace the animation with the default walking or idle animation, it will play perfectly fine in studio and in-game. Using my scripts apparently don’t work for some reason?
I hope I’m not missing something painfully obvious, but I really can’t tell why this happens.
thanks in advance for any help…