Help with script error?

I’ve currently finished my script and I’m debugging, but it’s saying…image

I’m not really sure what is wrong here but If you could help fix it that would be helpful!

Code:

local button = game.Workspace.Button
local object = script.Parent
local clickdetector = button.ClickDetector

function onMouseClick(player)
	
object.AnchorPoint = Vector2.new(0, 0)
object.Position = UDim2.new(1, 0, 0.905, 0)
	wait(0.5)
object:TweenPosition(UDim2.new(0.837, 0, 0.905, 0))
	wait(8)	
object:TweenPosition(UDim2.new(1, 0, 0.905, 0))
	button.BrickColor = BrickColor.Green()
end

clickdetector.MouseClick:connect(onMouseClick)

The Button object doesn’t exist in the workspace.

image

It does…?

Add game.Loaded:Wait() at the top of the script and try again. Maybe the script runs before the game fully loads the part.