Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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??

1 comment

0

You have not defined Frame variable.

2 answers

✓ Accepted answer

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.

1 comment

0

Tip, When you see Line [number] at a error. I'd suggest you look there then.

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".

This discussion is preserved as it was. New answers, comments, and votes are closed.