Advertisement
njeuro007

Roblox check how many players scripts เช็คจำนวนคนในแมฟ

Jun 17th, 2022
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1.  
  2. Roblox check how many players scripts
  3. Marcel12311
  4. Jan 20th, 2022
  5. 1,119
  6. Never
  7. 1.77 KB
  8.  
  9. --[[ Roblox check how many players are on the server
  10. INSTRUCTION:
  11. --
  12. 1.First Create ScreenGui and inside ScreenGui create Frame and inside Frame create TextLabel and can u edit property for your needs...
  13. 2.inside (TextLabel) create Local Script and edit it.. put this script called LOCAL SCRIPT
  14. 3.inside ServerScriptService create script and put scripts called SCRIPT (just edit the script)
  15. 4.ReplicatedStorage create RemoteEvent and dont change name..
  16. 5.Run Game!
  17. 6.Finish...
  18. --
  19.  
  20. if you have problem with understanding... I posted a video here:
  21. https://www.youtube.com/watch?v=1HY4aTTheaA
  22.  
  23. Enjoy guys!
  24. ]]--
  25. ---------------------------------------------------------------------
  26. ---------------------------------------------------------------------
  27. --LOCAL SCRIPT
  28. local textLabel = script.Parent
  29. local remoteEvent = game.ReplicatedStorage.RemoteEvent
  30.  
  31. local function onEvent(numbers)
  32. textLabel.Text = "Players: ".."("..numbers.."/"..game.Players.MaxPlayers..")"
  33. end
  34.  
  35. remoteEvent.OnClientEvent:Connect(onEvent)
  36. ---------------------------------------------------------------------
  37. ---------------------------------------------------------------------
  38. --SCRIPT
  39. local remoteEvent = game.ReplicatedStorage.RemoteEvent
  40. -- variable stores the number of players on the server
  41. local PlayersOnServer = 0
  42.  
  43.  
  44.  
  45. local function onJoin(plr)
  46. if plr then
  47. PlayersOnServer+=1
  48. remoteEvent:FireAllClients(PlayersOnServer)
  49. end
  50. end
  51.  
  52. local function onLeft(plr)
  53. if plr then
  54. PlayersOnServer-=1
  55. remoteEvent:FireAllClients(PlayersOnServer)
  56. end
  57. end
  58.  
  59. game.Players.PlayerAdded:Connect(onJoin)
  60. game.Players.PlayerRemoving:Connect(onLeft)
  61. ---------------------------------------------------------------------
  62. ---------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement