Hey guys!
I have this problem where I just get an error when I try to tween something in the PlayerGui. I have never got this error before and I have used the tween function many times.
Error: Can only tween objects in the workspace
Hey guys!
I have this problem where I just get an error when I try to tween something in the PlayerGui. I have never got this error before and I have used the tween function many times.
Error: Can only tween objects in the workspace
Well if you could send the code I could probably help you
I’m pretty sure it means it has to be a descendant of game
It’s 578 lines. Since it’s a whole GUI system it would be kinda hard. I use the tween function over 70 times in the script and it just doesn’t work on that special ScreenGui.
Then just send us the small snippet?
local taskManager = game:GetService("Players").LocalPlayer.PlayerGui.Manager.Manager
taskManager:TweenPosition(UDim2.new(1.2, 0, .483, 0), Enum.EasingDirection.In, Enum.EasingStyle.Sine, 0, true)
Are you sure the UI isn’t parented to nil before you tween it?
No, what exactly does that mean?
Like if taskManager.Parent ~= nil
How exactly do I check that? Within the explorer?
Oh, I understand, I’m sure yes.
Okay so after a while I manage to solve my problem and I wanted to share my solution so I can help others.
The best way to get the GUI that you want to tween is to use :WaitForChild
but you can not assign a variable all the way to the object you are tweeting. I first tried doing this:
local PlayerGui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
local taskManager = PlayerGui:WaitForChild("Manager"):WaitForChild("Manager")
taskManager:TweenPosition(UDim2.new(1, 0, .483, 0), Enum.EasingDirection.In, Enum.EasingStyle.Sine, 0, true)
That doesn’t work tho as I explained before. So instead I took the PlayerGui and assigned the object from there.
local PlayerGui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:WaitForChild("Manager"):WaitForChild("Manager"):TweenPosition(UDim2.new(1, 0, .483, 0), Enum.EasingDirection.In, Enum.EasingStyle.Sine, 0, true)
This should work if you have done it right.