Live player count help

I’m currently using a hub game that possess a script with just this in it, it’s designed to show a live player count on a text label but it doesn’t, does anyone know why this could be?

game.ReplicatedStorage.PlayerCount.OnClientEvent:Connect(function(id,data)
script.Parent:FindFirstChild(id).TextLabel.Text = id…" - "…data…“0/100”
end)

Your script is messy, and doesn’t do anything.

game.ReplicatedStorage.PlayerCount.OnClientEvent:Connect(function(id,data)
  script.Parent:FindFirstChild(id).TextLabel.Text = id…" - "…data…“0/100”
end)

What is “id”? And what data is it getting?

ID should be calling to I assume the ID in replicated storage, It’s got the universe ID in it.

You should be getting the value then, your calling a instance instead.

game.ReplicatedStorage.PlayerCount.OnClientEvent:Connect(function(id,data)
  script.Parent:FindFirstChild(id).TextLabel.Text = id.Value…" - "…data…“0/100”
end)

Although, this isn’t the method of how you actually get the live players, don’t know what your doing with it but I can help farther if needed.

It’s a buddy’s script from his old game, he said I can use, he’s rarely on anymore to help with it, not sure if I broke it or what not.

It might be a deprecated feature now, so yeah.

Not sure if this helps, but the circled local script is the script in question.

dev help

Yeah so, just use the script I provided in the other post, should work out.

You were calling the instance, “id”, which doesn’t give much information back, and you would rather want to get the Value of it.

Id is a parameter in the function. I don’t know why you’re attaching .Value to it.

1 Like

He might be calling the Instance, but yeah don’t know what he’s sending in the request.

1 Like

Yeah, this brings me to my main question: what is the RemoteEvent even passing in the first place?

Will this cause any problems?

1 Like

Why are you using 3 dots? It’s only suppose to be 2.

You can check the error by hovering over the red line.

1 Like

I just copied and pasted your script.

I was using your script…

Also your script is really really confusing, it might be time to start over from scratch man.

image
What are you refrencing here??? Your mentioning the id in a lot of stuff??


image

Can you please provide the script where it sends the request, and the parameters in it??

I don’t need that script, I want the script where it sends the remote request.

I’m not entirely sure, I’m not a scripter just trying to fix an old friends script for my usage, these are the only two other scripts in game besides the one I’ve shown, apologies for not being able to narrow it down.

local hubHandle = workspace:WaitForChild(‘HUB’)

game:GetService(‘StarterGui’):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)

local guis = {
kingsLanding = script.Parent:WaitForChild(‘KingsLanding’),
credits = script.Parent:WaitForChild(‘Credits’),
updates = script.Parent:WaitForChild(‘Updates’),
}

local originalPos = {}

for i,v in pairs(guis)do
originalPos[i] = v.Adornee.Position
end

function moveUp(part)
local goal = {}
goal.Position = part.Raised.Value
local tweenInfo = TweenInfo.new(0.3)
local tween = game:GetService(‘TweenService’):Create(part, tweenInfo, goal)
tween:Play()
end

function moveDown(part)
local goal = {}
goal.Position = part.Original.Value
local tweenInfo = TweenInfo.new(0.3)
local tween = game:GetService(‘TweenService’):Create(part, tweenInfo, goal)
tween:Play()
end

guis.kingsLanding.Frame.MouseEnter:Connect(function()
moveUp(guis.kingsLanding.Adornee)
end)

guis.kingsLanding.Frame.MouseLeave:Connect(function()
moveDown(guis.kingsLanding.Adornee)
end)

for i,v in pairs(guis)do
v.Frame.MouseEnter:Connect(function()
moveUp(v.Adornee)
script.Hover:Play()
end)
v.Frame.MouseLeave:Connect(function()
moveDown(v.Adornee)
end)
end

–[[guis.kingsLanding.Frame.Play.MouseButton1Click:Connect(function()
–script.Play:Play()
–game.ReplicatedStorage.RemoteEvent:FireServer(1)
–end)
–]]

function disableOthers(exception)
for i,v in pairs(guis.kingsLanding.Frame:GetChildren())do
if v:IsA(‘ImageButton’) and v.Name ~= exception then
v.Visible = false
end
end
end

guis.kingsLanding.Frame.Server1.MouseButton1Click:Connect(function()
disableOthers(‘Server1’)
script.Play:Play()
game.ReplicatedStorage.RemoteEvent:FireServer(1)
end)

guis.kingsLanding.Frame.Server2.MouseButton1Click:Connect(function()
disableOthers(‘Server2’)

script.Play:Play()
game.ReplicatedStorage.RemoteEvent:FireServer(2)

end)

guis.kingsLanding.Frame.Server3.MouseButton1Click:Connect(function()
disableOthers(‘Server3’)
script.Play:Play()
game.ReplicatedStorage.RemoteEvent:FireServer(3)
end)

for i,v in pairs(guis.credits.Frame.ImageLabel.ScrollingFrame:GetChildren())do
if v:IsA(‘Frame’) then
v.Icon.Image = ‘https://www.roblox.com/headshot-thumbnail/image?userId=’… v.Name … ‘&width=420&height=420&format=png’
end
end

while wait() do
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CFrame = hubHandle.Camera.CFrame
end

local datastoreService = game:GetService(‘DataStoreService’)
local teleportService = game:GetService(‘TeleportService’)
local dataStore = datastoreService:GetGlobalDataStore(‘Servers’)

local DSS = game:GetService(“DataStoreService”)
local DS = DSS:GetGlobalDataStore()
local ms = game:GetService(“MessagingService”)

local placeId = game.ReplicatedStorage:WaitForChild(‘id’).Value

local servers = require(game.ReplicatedStorage:WaitForChild(‘Servers’))

local serverTable = nil
– Never just use getasync by itself.
local succ = false;
local att = 0
repeat
local s,e = pcall(function()
serverTable = dataStore:GetAsync(‘serverTable’)
end)
succ = s
if not s then
warn('serverTable encountered a getasync issue: ’ … e)
end
att += 1
wait(1)
until succ or att >= 3

if not serverTable then
warn(‘serverTable is empty. ignoring’)
else
servers.server1 = serverTable.server1 or nil – the ‘or nil’ is just for safety
servers.server2 = serverTable.server2 or nil
servers.server3 = serverTable.server3 or nil
servers.code1 = serverTable.code1 or nil – the ‘or nil’ is just for safety
servers.code2 = serverTable.code2 or nil
servers.code3 = serverTable.code3 or nil

end

if servers.server1 == nil then
print(1)
local accessCode, privateServerId = teleportService:ReserveServer(placeId)
servers.server1 = accessCode
servers.code1 = privateServerId
end

if servers.server2 == nil then
print(2)
local accesscode, privateServerId2 = teleportService:ReserveServer(placeId)
servers.server2 = accesscode
servers.code2 = privateServerId2
print(accesscode)
print(privateServerId2)
end

if servers.server3 == nil then
print(3)
local accesscode, privateServerId3 = teleportService:ReserveServer(placeId)
servers.server3 = accesscode
servers.code3 = privateServerId3
print(accesscode)
print(privateServerId3)
end

– whatever
dataStore:SetAsync(‘serverTable’, servers)

game.ReplicatedStorage:WaitForChild(‘RemoteEvent’).OnServerEvent:Connect(function(player, server)
if server == 1 then
teleportService:TeleportToPrivateServer(placeId, servers.server1, {player})
end
if server == 2 then
teleportService:TeleportToPrivateServer(placeId, servers.server2, {player})
end
if server == 3 then
teleportService:TeleportToPrivateServer(placeId, servers.server3, {player})
end
end)

game:GetService(“MessagingService”):SubscribeAsync(“Servers”, function(message)
local serverSwitchingSystem = require(game.ReplicatedStorage:WaitForChild(“ServerSwitchingSystem”))
local type, maxplayers, players, job, place = serverSwitchingSystem:Decode(message.Data)

if type == "+" then

end

end)

while true do
wait(0.5)
print(servers.code1)
print(servers.server1)
DS:SetAsync(servers.code1, servers.server1)
DS:SetAsync(servers.code2, servers.server2)
DS:SetAsync(servers.code3, servers.server3)
end

Sorry, I can’t really help you. I recommend learning scripting or the basics tbh.
Also I feel like his system is deprecated, and you could just make one from scratch, wouldn’t be hard.

Okay I’ll see what I can do, thank you for your time.

1 Like