What does "attempt to index nil with 'TweenPosition' " mean

So I’m trying to make a starting screen/loading screen that basically just drops down when the start button gets clicked, but it inevitably results in “attempt to index nil with ‘TweenPosition’”

This is the feedback that I received https://gyazo.com/e116f3818e76d22b9beb852606cfc345

This is the organization of the scripts and GUI’s https://gyazo.com/8ef948fa192dab1cdf9573168deb16e8

Does anybody know what this means or how to fix it?

local screen = script.Parent.screen
local playbutton = screen.ImageButton

print("step 1")

playbutton.Activated:Connect(function()

local function End()

Screen.Visible = false

print ("done")

end

Screen:TweenPosition(UDim2.new(0, 0,1, 0),"Out", "Quad", 0.5, false, End)

print ("step 2")

end)```
1 Like

TweenPosition is only a function for GUIS like Frame,TextLabel,TextButton,TextBox,etc. Screenguis are only holders for these guis.

Whatever you used to define Screen is nil.

so i need to change my variable?

Yes, you would have to change the value of the variable.

sorry im new to scripting

what does that mean

I’ll give a quick example:

local screen = guiObject.Frame.TextLabel
         ^                  ^
-- Variable Name     Variable Value

In your situation, the value of Screen does not exist in the hierarchy.

1 Like

so the variable value is what the variable name represents?

That would be correct.

Minimum Characters

3 Likes

You define the local variable “screen”, but then attempt to tween “Screen”. I’ve had this cause an issue for me before when I was newer to scripting, just be careful because local variables are case-sensitive. If this isn’t the issue then sadly I don’t know what else is causing the issue.

5 Likes