Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

2 comments

0

i can also make it that it spawns infront of the player or near and not above

0

Thanks, you can also find my game here if you wana try it: https://www.roblox.com/games/2436224110/Voteable

This discussion is preserved as it was. New answers, comments, and votes are closed.