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)
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)
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)