I am making a T-Pose animation in my game. If you press a button in starter GUI you "buy" the T-Pose animation. It is not working. Please tell me what is the problem and how can I fix it.

Here are the scripts:

This is a local script inside a button of starter gui:

local repstorage = game:GetService("ReplicatedStorage")
local emote = repstorage:WaitForChild("Animation", 100)
local serverstorage = game:GetService("ServerStorage")
local price = serverstorage.Animations.TPose
local TPose = serverstorage.Animations:WaitForChild("TPose", 100)

script.Parent.MouseButton1Down:Connect(function()
	local player = game.Players.LocalPlayer
	if player.leaderstats.Cash.Value >= price then
		player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - price
		local anim = player.Character.Humanoid:LoadAnimation(emote)
		anim:Play()
		print("Success!")
	end
end)

Please tell me what is the problem and how can I fix it. Thanks!

16 comments

0

you should play the animation from a localscript

0

It is still not working, and also doesn't shows any error in the output.

0

include some print()s in your code and try to find the source of the problem. so far i can only think the if condition in your server script is false

0

I included a "print("Success!")" after "anim:Play()". It didn't print anything.

0

if script.Parent is a GuiButton you should do script.Parent.MouseButton1Click not MouseButton1Down

0

I did that but it still didn't work.

0

what priority is the animation set to? just to make sure it is the case set it to action

0

the priority is action

0

nvm can u update the code?

0

updated

0

another possibility: WaitForchild() might be yielding the thread but not giving any warnings, remove the second arguments

0

um i thought you played the animation from the localscript? and MouseButton1Down to MouseButton1Click

0

Updated again. It shows one error in the output:| 21:16:48.850 - Animations is not a valid member of ServerStorage | even though there is a folder called animations in it.

0

Local scripts can’t access ServerStorage. Try using ReplicatedStorage instead.

0

correction: i was wrong, MouseButton1Down is an event of GuiButton sorry. what Denny9876 said is probably the problem i havent noticed that

0

IT WORKED! THANK YOU SO MUCH!!!!!!!!