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

Tweening GUIs: "attempt to index global 'Frame' (a nil value)" Why isn't it working?

Asked by 7 years ago
script.Parent.MouseButton1Click:connect(function()
    Frame:TweenPosition(UDim2.new(0.5, -200, 0, -200))
end)

-- 18:03:14.153 - Players.Player1.PlayerGui.ScreenGui.Frame.Exit.LocalScript:2: attempt to index global 'Frame' (a nil value) 18:03:14.155 - Stack Begin 18:03:14.155 - Script 'Players.Player1.PlayerGui.ScreenGui.Frame.Exit.LocalScript', Line 2

18:03:14.155 - Stack End

Why isn't it working??

0
You have not defined Frame variable. User#5423 17 — 7y

2 answers

Log in to vote
2
Answered by 7 years ago

You forgot to define "Frame"

Here's the correct one!

script.Parent.MouseButton1Click:connect(function()
    script.Parent.Parent:TweenPosition(UDim2.new(0.5, -200, 0, -200)) -- This is not sure. A button is mostly in a frame. So the parent of the button is now seleted to be tweened.
end)

These faults can happen! Make sure to check your scripts multiple times. This is a starter fault. You will learn it how to fix it your self!

Hope I helped you! Have a good day.

0
Tip, When you see Line [number] at a error. I'd suggest you look there then. Difined_Person 61 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

It looks like you haven't defined the variable. If the frame you are referring to is the frame in the error directory (Players.Player1.PlayerGui.ScreenGui.Frame) then the proper way to address the frame would be "script.Parent.Parent".

Answer this question