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)

5 comments
They are inside a ScreenGui. "Cannon-Popup" is a ScreenGui. When the function is ran, the first argument for the gui parameter is: GUI. (What ever I want to reference here.)
My bad, I didn't notice that
Here is the issue, and I am wondering if you know the solution. On line 08, when I try to reference the parameter, it won't let me. Any idea how to get around that? I tried using variables, nothing like that worked.
What I mean by "it won't let me", is it won't work. The error takes me to line 08, and I believe its cause I can't directly reference the parameter like that.
You're using a LocalScript, correct?