I’m trying to play a few animations, but they aren’t playing. There is no error in the output window, but they won’t play. Here is the code:
local fridgePromt = script.Parent.MiddleShelf.FridgePrompt
local animator = script.Parent.FridgeCore.AnimationController.Animator
local openAnimation = Instance.new("Animation")
openAnimation.AnimationId = "rbxassetid://9120222702"
local openAnimTrack = animator:LoadAnimation(openAnimation)
local closeAnimation = Instance.new("Animation")
closeAnimation.AnimationId = "rbxassetid://9120235633"
local closeAnimTrack = animator:LoadAnimation(closeAnimation)
fridgePromt.Triggered:Connect(function(plr)
local PlayerGui = plr:WaitForChild("PlayerGui")
wait(0.3)
local fridgeGui = PlayerGui.FridgeGUI.FridgeGUIFrame
while fridgeGui.Visible == true do
wait(0.3)
end
openAnimTrack:Play()
wait(0.5)
closeAnimTrack:Play()
end)
You could try to debug the function first by adding a print("attempting to play") in front of the :Play() call. Is the “animator” created by the server?
Make a new dummy using the dummy creator plugin, unanchor the humanoidrootpart and apply your script to the character. If it works then it’s something with your rig and Motor6D’s, but if it doesn’t work, it’s something with your script. Although if it’s your script, I don’t know what to tell you, your script looks fine.
I have done some debugging, and I figured out it is a client-server issue.
while fridgeGui.Visible == true do
wait(0.3)
end
The code above is waiting for a player to click a button on a gui that shows up when they trigger the prompt. The button will make in not visible, but that is on the client side. As @Forummer explained to me in a different topic, as far as the server is concerned, the gui is still visible, so it will just keep waiting forever. I want to use RemoteEvents, but there will be multiple fridges in the restaurant, and I don’t want them all to open and close when someone triggers the prompt. How could I do this?