Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Roblox check how many players scripts
- Marcel12311
- Jan 20th, 2022
- 1,119
- Never
- 1.77 KB
- --[[ Roblox check how many players are on the server
- INSTRUCTION:
- --
- 1.First Create ScreenGui and inside ScreenGui create Frame and inside Frame create TextLabel and can u edit property for your needs...
- 2.inside (TextLabel) create Local Script and edit it.. put this script called LOCAL SCRIPT
- 3.inside ServerScriptService create script and put scripts called SCRIPT (just edit the script)
- 4.ReplicatedStorage create RemoteEvent and dont change name..
- 5.Run Game!
- 6.Finish...
- --
- if you have problem with understanding... I posted a video here:
- https://www.youtube.com/watch?v=1HY4aTTheaA
- Enjoy guys!
- ]]--
- ---------------------------------------------------------------------
- ---------------------------------------------------------------------
- --LOCAL SCRIPT
- local textLabel = script.Parent
- local remoteEvent = game.ReplicatedStorage.RemoteEvent
- local function onEvent(numbers)
- textLabel.Text = "Players: ".."("..numbers.."/"..game.Players.MaxPlayers..")"
- end
- remoteEvent.OnClientEvent:Connect(onEvent)
- ---------------------------------------------------------------------
- ---------------------------------------------------------------------
- --SCRIPT
- local remoteEvent = game.ReplicatedStorage.RemoteEvent
- -- variable stores the number of players on the server
- local PlayersOnServer = 0
- local function onJoin(plr)
- if plr then
- PlayersOnServer+=1
- remoteEvent:FireAllClients(PlayersOnServer)
- end
- end
- local function onLeft(plr)
- if plr then
- PlayersOnServer-=1
- remoteEvent:FireAllClients(PlayersOnServer)
- end
- end
- game.Players.PlayerAdded:Connect(onJoin)
- game.Players.PlayerRemoving:Connect(onLeft)
- ---------------------------------------------------------------------
- ---------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement