Function works in studio but not in the published game

So, I’m trying to make a function in a game but, the function only works in studio but not in the actual game.

In Studio:

In the published version:

Any help is appreciated.

1 Like

You need to put in more information, send us your code otherwise we’re not sure what to fix! But I understand your problem has no explanation and we should be the ones helping you completely.
Uh, try pressing F9 in the game to check any errors or unloaded assets. I think your animation hasn’t been moderated yet. Have you put the assetid in the script and then made the animation in the script?
Or saved it as an instance under the script, that seems to work best. Tell me what happens good luck!
Edit: Sorry just realised your cursor also hadn’t appeared, it seems to be VERY sus on the asset side of things.

Ok, so, I animated the animation, then put it into the script, and after over 5 hours, it still doesn’t work. And here’s the script for the animation. I put the script into StarterCharacterScripts:

local Animation = Instance.new("Animation")

Animation.AnimationId = "rbxassetid://5919555388"

local track

local ClickDetector = game.Workspace.Meshescat.ClickDetector

ClickDetector.MouseClick:Connect(function()

track = script.Parent.Parent.Humanoid:LoadAnimation(Animation)

track.Priority = Enum.AnimationPriority.Action

track.Looped = false

track:Play()

end)

And no, there are no errors.

Oh and the asset has been accepted 5 hours ago as well.

Might want to see Animations Breaking after Update. A patch just came out that fixed animations. Maybe test the game now and see if it works?

1 Like

Kk, that seems better. I think you should make an animation instance in studio inside of the script using the + sign next to the script and put the id there, then load the animation in teh script and then the character. Also Vulkarin is probably correct because I am just going off of the developer api and experience.

Edit: Script:
local Animation = script:WaitForChild(“HitCatAnimation”)

local track

local ClickDetector = game.Workspace.Meshescat.ClickDetector

ClickDetector.MouseClick:Connect(function()

track = script.Parent.Parent.Humanoid:LoadAnimation(Animation)

track.Priority = Enum.AnimationPriority.Action

track.Looped = false

track:Play()

end)

Script could be incorrect so check it and come back to me but put an animation called “HitCatAnimation” with the id in the script :D, i don’t think you can just produce an animation like that because exploiters could REALLY abuse that maybe its filtered if you make the anim in the script itself to prevent bad anims from hacks as it is not safely replicated from server and verified as an animation the server has replicated and uses as if it was an instance under the script

Yeah it didn’t really work at all.

Ye probably the broken animation thing, that works in my game perfectly on client and studio. Maybe somebody else has a better insight? Good luck i will come back if something else comes to mind idk

Humanoid:LoadAnimation() has been deprecated, and may not function properly. Instead, try replacing that bit of code with this:

local humanoid = script.Parent.Parent:WaitForChild("Humanoid")
local animator = humanoid:FindFirstChildWhichIsA("Animator")

if animator then
    track = animator:LoadAnimation(Animation)
end

I tried replacing the function with the function you gave me and it doesn’t work

Any errors in the output window?

No errors. It is completely clean.

I rewrote your script a bit, try and see if this helps:

(LocalScript inside of StarterCharacterScripts)

local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:FindFirstChildOfClass("Animator")

if not animator then
    animator = Instance.new("Animator")
    animator.Parent = humanoid
end

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://5919555388"
animation.Parent = humanoid

local track = animator:LoadAnimation(animation)
track.Priority = Enum.AnimationPriority.Action
track.Looped = false

workspace.Meshescat.ClickDetector.MouseClick:Connect(function()
    track:Play()
end)

I just scripted this quickly, and didn’t test it. If it errors, please let me know.

Works in studio but not in the published game. And there are no errors.