So, I have made a function that does GUI tweening, with 1 of the parameters representing the GUI that gets tweened. I tried putting the parameter in a variable.
Here is the script:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("CannonGuiAppear") remoteEvent.OnClientEvent:Connect(function() local GUI = script.Parent.Parent.PlayerGui["Cannon-Popup"] local function GuiTween(gui,posX, poxY) gui:TweenPosition( UDim2.new(posX, 0, poxY, 0), "Out", -- Easing Direction "Sine", -- Easing Style 1, true, game.Workspace.Cannon.Part.Controls.Disabled == false ) end GuiTween(GUI.Frame1, 0.62, 0.898) GuiTween(GUI.Frame2, 0.261,0.929) GuiTween(GUI.Frame3,0.318,0.898) GuiTween(GUI.Frame4, 0.62,0.929) GuiTween(GUI.Frame5,0.357,0.859) GuiTween(GUI.TextLabel,0.357,0.88) end)
And here is the error: 17:09:07.156 - Unable to cast value to function for the line that says; gui:TweenPosition(
Any idea how I can fix this? And yes, the remote event CAN run without issue of triggering it.
Note: This is a local script in StarterPlayerScripts (transferred to PlayerScripts in each player)
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("CannonGuiAppear") local function GuiTween(gui,posX, poxY) gui:TweenPosition( UDim2.new(posX, 0, poxY, 0), "Out", -- Easing Direction "Sine", -- Easing Style 1, true, function() -- Make this a function game.Workspace.Cannon.Part.Controls.Disabled = false end ) end remoteEvent.OnClientEvent:Connect(function() local GUI = script.Parent.Parent.PlayerGui["Cannon-Popup"] GuiTween(GUI.Frame1, 0.62, 0.898) GuiTween(GUI.Frame2, 0.261,0.929) GuiTween(GUI.Frame3,0.318,0.898) GuiTween(GUI.Frame4, 0.62,0.929) GuiTween(GUI.Frame5,0.357,0.859) GuiTween(GUI.TextLabel,0.357,0.88) end)
You cannot tween the position of StarterGui
's themselves. It only works on elements inside of a ScreenGui, such as a Frame or an ImageLabel.