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

error : attempt to index nil with 'Position' how do I fix ?

Here is the script (for a pop up)

for i = 1,20 do
	script.Parent.Position = UDim2.new(math.random(20,60)/250,0,math.random(20,60)/250,0)
	script.Parent:TweenSize(UDim2.new(0, 250,0, 250),"Out","Bounce",1,true)
	wait(1.5)
	script.Parent:TweenSize(UDim2.new(0, 250,0, 250),"Out","Linear",0.3,true)
	wait(0.4)
	script.Parent:Destroy()
end

2 answers

✓ Accepted answer

I'm asuming your error is here: script.Parent.Position = since i don't see any other .Position anywhere else inside the for loop.

You are receiving that error because you destroy the parent object script.Parent:Destroy() at the end of that iteration of the loop, then once it goes to the next number the parent object is not there anymore because it was destroyed

2 comments

0

oh thanks :)

0

yeah it works changed the script

Is the script parented a GuiObject [Frame/ScrollingFrame/ViewportFrame/TextLabel/TextButton/ImageLabel/ImageButton]? If not, parent it to a guiObject!

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