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

Can someone show me a better way to use this script?

Asked by
Irvene 5
10 years ago

I need it bugless, so I'm asking if someone could help me out here, by showing me if there's any bugs and fixing them possibly.

Script:

A = game.Players

if A.NumPlayers == 1 then print("There's not enough players in the game for the game to start.")
A2 = "Welcome to the official meadows sfing game"
A4 = "5"
A3 = "The amount of players is successful, and the game will be starting in" .. A4 .. "Seconds.."
A4 = "Teaming players..."


elseif not NumPlayers < 1 then
    print(NumPlayers.." Is the amount of players in the game.")
    wait(0.1)
    if A.NumPlayers == NumPlayers >2 then
    print("Success")
    wait(3)
    elseif A.NumPlayers == NumPlayers <1 then
        print("Denial")
        wait(3)
    while true do
    local M = Instance.new("Message",workspace)
    M.Text = A2
    wait(1)
    M.Text = A3
    wait(0.1)
function fixTeams()
         BlueTeam = clones[1].Parent = game.Teams -- This is the blue team
         RedTeam = clones[2].Parent = game.Teams -- This is the red team
         end
         wait(3)
         M.Text = A4


function checkSpectators()
          spectators = 0
          for _, player in pairs(game.Players:GetChildren()) do
          if(player.TeamColor == SpectatorColor) then
          spectators = spectators + 1
          end
          end
          if(spectators == game.Players.NumPlayers) then
          BlueTeam:Destroy()
          RedTeam:Destroy()
          Wait(3)


function findwinner()
        players = 0
        BlueTeam = game.Teams.BlueTeam.BrickColor.new = "Bright blue"
        for _, player in pairs(game.Players:GetChildren()) do
        if(player.TeamColor == BlueTeamColor) then
        players = BlueTeamColor + 1
        wait(5)
        if players = 0 then
        print("Blue team has lost")
        else
        print("Red team has lost")


end
end
end
end
end





1 answer

Log in to vote
2
Answered by 10 years ago

Many problems here, I'll list them out.

1) You set the A4 value to two different things.

2) Instead of "elseif not Numplayers > 1" use "elseif A.NumPlayers > 1". Also ,you didn't set that to "A.NumPlayers".

3) You haven't set the NumPlayers variable in the script, so right now it means nothing. Set NumPlayers to A.NumPlayers.

4) The while true do loop on line 19 will make sure that nothing after it runs. Also, that part seems pretty useless, it would constantly have a message on the screen. And you forgot to add an end to that while loop.

5) You haven't set the clones to anything, unless you don't have another part of the script included.

6) SpectatorColor has not been set to anything. Instead, replace line 36 with this:

if player.TeamColor == game.Teams.Spectators.TeamColor then

7) No end to the if statement on lines 40-43.

8) Line 48 is... strange. That wouldn't work at all, if you want to set BlueTeam as a variable, equal to the Blue Team's TeamColor, then use something like this:

BlueTeam = game.Teams.BlueTeam.TeamColor

9) You got the variable wrong on line 50, it's not "BlueTeamColor" it's just "BlueTeam".

10) Line 51 is messed up, rather than players = BlueTeamColor + 1, use players = players + 1.

11) Also, on line 56, you're printing that the red team has won even if there are players left on the blue team. You should probably add the red team to the loop you created there.

12) And finally, you have no connection lines. This mean that your functions will never run, unless you call them.

I won't write the code for you, but take into account what I said, and be more careful when you're coding next time. Hope I helped!

Ad

Answer this question