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

Is my scripting right on this and will it work?

Asked by 9 years ago

I want to make sure all my scripting is right. I am trying to make this so if the max players are online spawn the becon but if they are not delete it.

01if game.Players.MaxPlayers:connect(function(player) == true do
02local c = game.ServerStorage.Becon:Clone()
03c.Parent = game.Workspace
04c.Position = Vector3.new(42,0.5,-25)
05end)
06else
07end
08if game.workspace.Becon do
09if game.Players.MaxPlayers:connect(function(player) ~= do
10game.workspace.Becon:Destroy()
11end
12end

1 answer

Log in to vote
1
Answered by
u_g 90
9 years ago

The if statements are not correctly used, and the event is not valid. Try this one, instead:

01game.Players.ChildAdded:connect(function(player) -- This will connect every time a player is added
02local numberofPlayers = game.Players:GetChildren()
03numberofPlayers = #numberofPlayers
04 
05if game.Players.MaxPlayers == numberofPlayers then
06 
07local c = game.ServerStorage.Becon:clone()
08c.Parent = game.Workspace
09c.Position = Vector3.new(42,0.5,-25)
10 
11end
12end)
13 
14 
15game.Players.ChildRemoved:connect(function(player) -- This'll connect every time a player is removed
View all 28 lines...
Ad

Answer this question