Hello,
I’m currently trying to create a tween created via a ModuleScript, however I’m getting the error “Can only tween objects in the workspace”. Here’s my code:
local function pushMenu(nextMenu, prevMenu)
if prevMenu then
prevMenu:TweenPosition(UDim2.new(-1, 0, 0, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 1, true)
end
-- more code here, not related to the error
end
-- For example, trying to run:
local mainFrameShield = Instance.new('Frame')
mainFrameShield.Name = "mainFrameShield"
mainFrameShield.Size = UDim2.new(1, 0, 1, 36)
mainFrameShield.Position = UDim2.new(0, 0, 0, -36)
mainFrameShield.BackgroundTransparency = 1
mainFrameShield.BackgroundColor3 = Color3.new(31/255, 31/255, 31/255)
mainFrameShield.BorderColor3 = Color3.new(27/255, 42/255, 53/255)
mainFrameShield.BorderSizePixel = 0
mainFrameShield.Visible = false
mainFrameShield.ZIndex = 3
mainFrameShield.Parent = mainSGUI
mainFrame = Instance.new('Frame')
mainFrame.Name = "mainFrame"
mainFrame.Size = UDim2.new(1, 0, 1, 0)
mainFrame.Position = closed_Position
mainFrame.Active = true
mainFrame.BackgroundTransparency = 0.65
mainFrame.BackgroundColor3 = Color3.new(31/255, 31/255, 31/255)
mainFrame.BorderSizePixel = 0
mainFrame.ZIndex = 4
mainFrame.ClipsDescendants = true
mainFrame.Parent = mainFrameShield
local function createMenuFrame(name, position)
local frame = Instance.new('Frame')
frame.Name = name
frame.Size = UDim2.new(1, 0, 1, 0)
frame.Position = position
frame.BackgroundTransparency = 1
frame.ZIndex = 5
return frame
end
local rootMenuFrame = createMenuFrame("rootMenuFrame", UDim2.new(0, 0, 0, 0))
rootMenuFrame.Parent = mainFrame
pushMenu(rootMenuFrame, rootMenuFrame)
will return error “Can only tween objects in the workspace”.
Been stuck on this for about an hour and have no clue what’s going on. Anyone able to help out, please? Has to be created using a Script.
Thanks,
p0s_0