Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[Solved]This animation button is not working. It is in starter gui, what is the problem?

Asked by 5 years ago
Edited 5 years ago

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!

0
you should play the animation from a localscript GoldAngelInDisguise 297 — 5y
0
It is still not working, and also doesn't shows any error in the output. StrategicPlayZ 58 — 5y
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 GoldAngelInDisguise 297 — 5y
0
I included a "print("Success!")" after "anim:Play()". It didn't print anything. StrategicPlayZ 58 — 5y
View all comments (12 more)
0
if script.Parent is a GuiButton you should do script.Parent.MouseButton1Click not MouseButton1Down GoldAngelInDisguise 297 — 5y
0
I did that but it still didn't work. StrategicPlayZ 58 — 5y
0
what priority is the animation set to? just to make sure it is the case set it to action GoldAngelInDisguise 297 — 5y
0
the priority is action StrategicPlayZ 58 — 5y
0
nvm can u update the code? GoldAngelInDisguise 297 — 5y
0
updated StrategicPlayZ 58 — 5y
0
another possibility: WaitForchild() might be yielding the thread but not giving any warnings, remove the second arguments GoldAngelInDisguise 297 — 5y
0
um i thought you played the animation from the localscript? and MouseButton1Down to MouseButton1Click GoldAngelInDisguise 297 — 5y
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. StrategicPlayZ 58 — 5y
0
Local scripts can’t access ServerStorage. Try using ReplicatedStorage instead. User#20279 0 — 5y
0
correction: i was wrong, MouseButton1Down is an event of GuiButton sorry. what Denny9876 said is probably the problem i havent noticed that GoldAngelInDisguise 297 — 5y
0
IT WORKED! THANK YOU SO MUCH!!!!!!!! StrategicPlayZ 58 — 5y

Answer this question