Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Problem with GUI tweening and parameters. How can I fix it?

Asked by 4 years ago
Edited 4 years ago

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:

01local ReplicatedStorage = game:GetService("ReplicatedStorage")
02local remoteEvent = ReplicatedStorage:WaitForChild("CannonGuiAppear")
03 
04remoteEvent.OnClientEvent:Connect(function()
05    local GUI = script.Parent.Parent.PlayerGui["Cannon-Popup"]
06    local function GuiTween(gui,posX, poxY)
07 
08        gui:TweenPosition(
09                UDim2.new(posX, 0, poxY, 0),
10                "Out", -- Easing Direction
11                "Sine", -- Easing Style
12                1,
13                true,
14                game.Workspace.Cannon.Part.Controls.Disabled == false
15            )
View all 24 lines...

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)

2 answers

Log in to vote
0
Answered by 4 years ago
01local ReplicatedStorage = game:GetService("ReplicatedStorage")
02local remoteEvent = ReplicatedStorage:WaitForChild("CannonGuiAppear")
03 
04local function GuiTween(gui,posX, poxY)
05    gui:TweenPosition(
06        UDim2.new(posX, 0, poxY, 0),
07        "Out", -- Easing Direction
08        "Sine", -- Easing Style
09        1,
10        true,
11        function() -- Make this a function
12            game.Workspace.Cannon.Part.Controls.Disabled = false
13        end
14    )
15end
View all 26 lines...
Ad
Log in to vote
0
Answered by
zane21225 243 Moderation Voter
4 years ago

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.

0
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.) cookie_more 30 — 4y
0
My bad, I didn't notice that zane21225 243 — 4y
0
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. cookie_more 30 — 4y
0
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. cookie_more 30 — 4y
0
You're using a LocalScript, correct? zane21225 243 — 4y

Answer this question