Why am i getting this error?

This error keeps preventing me from opening my gui it works in some games but not others?

Ive had to change the name of “ScreenStuff” so much times and it wont fix

it was working fine in my game where I test stuff but as I copied it over from that game to one place it does not work but in other places when I copy it it does

1 Like

local TheUi = player:WaitForChild("PlayerGui"):WaitForChild("ScreenStuff")

Can you paste the code in Lua format instead of a screenshot?

This was meant for the creator of the post not you, sorry.

local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SpawnCarEvent = ReplicatedStorage:WaitForChild("SpawnCar")
local DeleteCarEvent = ReplicatedStorage:WaitForChild("DeleteCar")
local carName = script.Parent.Name
local SpawnCarFrame = script.Parent.Parent.Parent.Parent.ShopMain
local open = script.Parent.Parent.Parent.Parent.spawn
local Screenhide = script.Parent.Parent.Parent.Parent.Parent.ScreenStuff


script.Parent.MouseButton1Click:Connect(function()  
	SpawnCarFrame:TweenPosition(UDim2.new(1, 5,0, 0),"Out","Quint",0.5,true)
	open.Visible = true
	Screenhide.Enabled = true
	local CurrentCar = game.Workspace:FindFirstChild(player.Name .. 'sCar')
	if not CurrentCar then
		SpawnCarEvent:FireServer(carName)
	else
		if player.Character.Humanoid.SeatPart ~= nil and player.Character.Humanoid.SeatPart:IsA("VehicleSeat") then
			player.Character.Humanoid.Sit = false
		end
		wait()
		DeleteCarEvent:FireServer(CurrentCar)
		SpawnCarEvent:FireServer(carName)
	end
end)
local CarSpawnerFrame = script.Parent.Parent.ShopMain
local TheUi = script.Parent.Parent.Parent.ScreenStuff
local Garageicn = script.Parent.Parent.spawn

script.Parent.MouseButton1Click:Connect(function()

CarSpawnerFrame:TweenPosition(UDim2.new(0, 0,0, 0),"Out","Quint",0.5,true)

end)

script.Parent.MouseButton1Click:Connect(function()

TheUi.Enabled = false

end)

script.Parent.MouseButton1Click:Connect(function()

Garageicn.Visible = false

end)
1 Like

This did not work unfortunately

local TheUi = script.Parent.Parent.Parent:WaitForChild("ScreenStuff")

Snipping since no longer relevant.

His error is within the Open Handler so if he adds the code below into the Open Handler

local TheUi = script.Parent.Parent.Parent:WaitForChild("ScreenStuff")

it will work.

i put it in the second script

characterlimittttt

I didn’t see that other script until just now, I think the original post was edited.

You should probably add waits on everything, especially when you’re referencing instances from other “ScreenGui” instances.

put a wait after each end) in the this?

local CarSpawnerFrame = script.Parent.Parent.ShopMain
local TheUi = script.Parent.Parent.Parent.ScreenStuff
local Garageicn = script.Parent.Parent.spawn

script.Parent.MouseButton1Click:Connect(function()

CarSpawnerFrame:TweenPosition(UDim2.new(0, 0,0, 0),"Out","Quint",0.5,true)

end)

script.Parent.MouseButton1Click:Connect(function()

TheUi.Enabled = false

end)

script.Parent.MouseButton1Click:Connect(function()

Garageicn.Visible = false

end)

local CarSpawnerFrame = script.Parent.Parent:WaitForChild("ShopMain")

Like this, so it allows the instance to load before attempting to create a variable reference for it.