Frame that only visible for vip servers owner only error

Im trying to achieve is to make the frame visible only on vip servers.

local scripts :

game.Players.PlayerAdded:Connect(function(plr)
	if plr.UserId == game.PrivateServerOwnerId then
		wait()
		script.Parent.Visible = false
	else
		wait()
		script.Parent.Visible = true
	end
end)
game.Players.PlayerAdded:Connect(function(plr)
	if plr.UserId == game.PrivateServerOwnerId then
		wait()
		script.Parent.Visible = true
	else
		wait()
		script.Parent.Visible = false
	end

try this?

Still not heres the properties:
Untitled

local plr = game.Players.LocalPlayer
if plr.UserId == game.PrivateServerOwnerId then
	wait()
	script.Parent.Visible = true
else
	wait()
	script.Parent.Visible = false
end

try this

Still the same btw im using vip server since i said the frame only visible if it on vip server and only on owner of the vip server
.

Are you trying to make it so only the VipServer owner can see it? You can simply get the LocalPlayer in this case becuase PlayerAdded has no time to detect your localplayer being added

local plr = game:GetService("Players").LocalPlayer

if plr.UserId == game.PrivateServerOwnerId then
	wait()
	script.Parent.Visible = true
else
	wait()
	script.Parent.Visible = false
end

Although this is not a good way to go about it since you put the gui in everyone’s starterGui instead of only the vip’s owner, exploiters can just enable it themselves, it’s better to clone it into the vip server owner’s PlayerGui so only they can see it

And as @Creeperman16487 mentioned that I had forgot to state, it must be a regular script in ServerScriptService, which has a PlayerAdded event in it that checks if the player who joined’s id is the same as the vip owner, and if they’re the same, clone the gui that you placed in somewhere such as ServerStorage and put it in their PlayerGui

1 Like

Still not the solution but thanks for giving me idea i will just change it to clone.

1 Like

but once you change to clone it should be a server script