My game works local but running it on the server I get this error:

CMPTR is not a valid member of ScreenGui

local button = script.Parent
local startgui = button.Parent.Parent
local player = game.Players.LocalPlayer
local plyrgui = player.PlayerGui
local l = startgui.Buttons
local comp = plyrgui.Buttons.CMPTR
local compF = comp.Frame
local compT = comp.TextLabel

local function onButtonClick()
	
	print("Play Button Clicked")	
	
	l.PlayBut:Destroy()
	
	l.HelpBut:Destroy()
	
	l.AboutBut:Destroy()
	
	--compF.Size = UDim2.new(0, 900, 0, 450)
	--compF.Position = UDim2.new(0, 300, 0, 50)
	--compT.Size = UDim2.new(0, 850, 0, 400)
	--compT.Position = UDim2.new(0, 325, 0, 75)
	
	compT:TweenSizeAndPosition(UDim2.new(0, 850, 0, 400), UDim2.new(0, 275, 0, 75), "Out", "Quad", 1)
	compF:TweenSizeAndPosition(UDim2.new(0, 900, 0, 450), UDim2.new(0, 250, 0, 50), "Out", "Quad", 1)
	
end
 
button.MouseButton1Click:connect(onButtonClick)

I have looked over: https://scriptinghelpers.org/blog/it-works-in-studio-but-not-online a bit

Why do I get the error? Thankyou in advance!

5 comments

0

Is this a localScript?

0

Yes

0

try :WaitForChild() not everything loads when the player does

0

^

0

I added that in but I still get the error :/