Correct Parent but the script say it's wrong

  1. What do you want to achieve?

so i was making a server list , it’s kind of like a custom matchmaking gui.

  1. What is the issue?
    i don’t see anything wrong , but the script say it’s wrong . Look at the pictures below .

–This is the error

–The scripts

game.ReplicatedStorage.ServerCreation.CreationToServerAdded.OnClientEvent:Connect(function(owner, stype, pass)
	if game.Players.LocalPlayer.Name ~= owner then
		script.Parent.Parent.Main.ServerBrowser.TextLabel.Text = (owner..' has created a server! [MODE: '..stype..' ]')
		local serverFrame = script.Parent.server
		local serverList = script.Parent.list
		
		local listadded = serverFrame:Clone()
		
		listadded.Parent = serverList
		listadded.Name = owner
		listadded.password.Value = pass
		listadded.ServerOwner.Text = owner
		listadded.MapType.Text = ('Mode: '..stype)
		listadded.Type.Value = stype
		listadded.Visible = true

		wait(2)
		script.Parent.Parent.ServerBrowser.TextLabel.Text = ''
	end
end)

--[[UPDATER FOR THE SERVERS]]
game.ReplicatedStorage.ServerCreation.SlotUpdater.OnClientEvent:Connect(function(creator, val)
if game.Players.LocalPlayer.Name ~= creator then

      local list = script.Parent.list
      script.member.Value = val
      list:FindFirstChild(creator).Slot.Value = script.member.Value
else
	
	end
end)

--[Disband]
game.ReplicatedStorage.ServerCreation.CreationDisband.OnClientEvent:Connect(function(creator)
	if game.Players.LocalPlayer.Name ~= creator then
	script.Parent.Parent.Main.ServerBrowser.TextLabel.Text = (creator..' has disbanded a server!')
	script.Parent.list:FindFirstChild(creator):Destroy()
	wait(2)
	script.Parent.Parent.Main.ServerBrowser.TextLabel.Text = ''
	end
end)

– And the Explorer page here .
Capturebug

Please tell me if i do anything wrong .

did you mean to put script.Parent.Parent?
Your code line was:

local serverFrame = script.Parent.server

Change that line using this code instead:

local serverFrame = script.Parent.Parent.server -- added an extra '.Parent'

EDIT: Nevermind that is not the issue

but if i add 1 more parent , it’s definitely not correct .

1 Like

Please only make one thread on any given problem. If there is an update, you can edit the original thread.

Also, try this:

but this script only activate when somebody created a server , i’m pretty sure it’s all done loading .

Didn’t knew that there were multiple threads of this problem,

Explanation to OP:

To explain why I said use WaitForChild, clients needs to replicate instances from the server (which can take a while depending on the size), LocalScripts usually when run when the client is still replicating from the server which is why sometimes instances are missing said by the LocalScript when the instance actually does exist, this is because at runtime, the instance has not replicated, thus you have to wait for it to replicate with using Instance:WaitForChild(childName: string, [timeout: number]) (timeout parameter is optional).

Keep in mind WaitForChild yields the script until the timeout has passed (if specified within the arguments) or the instance was replicated and found (will return the instance)

1 Like

Is this a LocalScript or a normal Script?

I wasn’t meaning you, I meant the thread author.

2 Likes

its a local script . i have 2 server script which is teleporting the players and also the on server event thing .

Then as I said, try using Instance:WaitForChild(childName: string, [timeout: number])

is it normal that the script say “infinite yield possible” ? do i need to fix that??

now there is this error

Is there any other scripts referencing the frame?

When you run the game does the instance exist? (Use explorer)

i dont remember this , there is too much scripts in there.

i didnt see the explorer when i testing . i just gonna give you the model .

You can do a search of all your scripts by typing CTRL + SHIFT + F a typing in ‘server’ (without the quotation marks)

1 Like

You don’t know that. Please put in :WaitForChild()

Try making the variables outside of OnClientEvent, at the top of the LocalScript. And next time, you should add (at least) one WaitForChild() when making variables.

Try this code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local ServerCreation = ReplicatedStorage:WaitForChild("ServerCreation")
local player = Players.LocalPlayer

local serverFrame = script.Parent:WaitForChild("server")
local serverList = script.Parent:WaitForChild("list")


ServerCreation.CreationToServerAdded.OnClientEvent:Connect(function(owner, stype, pass)
	if player.Name ~= owner then
		local listadded = serverFrame:Clone()

		listadded.Parent = serverList
		listadded.Name = owner
		listadded.password.Value = pass
		listadded.ServerOwner.Text = owner
		listadded.MapType.Text = ('Mode: '..stype)
		listadded.Type.Value = stype
		listadded.Visible = true

		task.wait(2)
		script.Parent.Parent.ServerBrowser.TextLabel.Text = ''
	end 
end)

ServerCreation.SlotUpdater.OnClientEvent:Connect(function(creator, val)
	if player.Name ~= creator then

		script.member.Value = val
		serverList:FindFirstChild(creator).Slot.Value = script.member.Value
	else

	end
end)

--[Disband]
ServerCreation.CreationDisband.OnClientEvent:Connect(function(creator)
	if player.Name ~= creator then
		script.Parent.Parent.Main.ServerBrowser.TextLabel.Text = (creator..' has disbanded a server!')
		serverList:FindFirstChild(creator):Destroy()
		task.wait(2)
		script.Parent.Parent.Main.ServerBrowser.TextLabel.Text = ''
	end
end)
1 Like

Hey @HHeartlessHunteR , have you tried the code I gave you above? If you did, did it work?

1 Like