Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

(Server Script) How to know how many players are on the game?

Asked by 5 years ago

I need to make a script that creates one boat for each player...

This is what I got:

local RepStorage = game:WaitForChild("ReplicatedStorage")
local Remote = RepStorage:WaitForChild("GameRemote")

--Wait for players
game:WaitForChild("Players")
wait(1)
--FireClient
Remote:FireAllClients()
print("Countdown has been fired")
--FireClient
Remote.OnServerEvent:Connect(function(player)
    --Script goes here
end)

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

how to know how many players

local players = game.Players:GetPlayers()
print(#players)

spawn ship to every player

for i,v in pairs(game.Players:GetPlayers()) do
local clone = game.ServerStorage.Ship:Clone()
clone.Parent = workspace
clone:MoveTo(v.Character.Head.Position) -- do any position of any body part
end
0
i can also make it that it spawns infront of the player or near and not above Lolamtic 63 — 5y
0
Thanks, you can also find my game here if you wana try it: https://www.roblox.com/games/2436224110/Voteable retrobricks 162 — 5y
Ad

Answer this question