|
Really weird issue here, but in a game i'm making my tables don't work right?
What I have is it teleports the player into the game, and adds their name to a table, in the code below:
--Function to teleport players
function teleportPlayers()
displayMessage("Teleporting Players...")
for i,v in pairs(game.Players:GetChildren()) do
if v and v.Character then
v.Character.Torso.CFrame = CFrame.new(29, 64.4, 16.4)
v.TeamColor = BrickColor.new("Bright bluish green")
table.insert(Survivors, 1, v.Name)
print(#Survivors.."..Player Teleported")
displayMessage("Rising Lava...")
end
end
end
And the first tmie around it teleports all the players just fine and has the correct number of players E.G in play solo the output looks like this:
> 1..Player Teleported
But when it kills my character it should remove him from the table, with the code below:
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
if player.TeamColor == BrickColor.new("Bright bluish green") or player.TeamColor == "Bright yellow" then
player.TeamColor = BrickColor.new("Bright blue")
table.remove(Survivors, 1, player.Name)
print(#Survivors.."..Player Died")
if #Survivors <= 0 then --Lol, less then just in case
gameOver()
end
end
end)
end)
Now the problem is when the game (In play solo) restarts the table says it teleports 2 players in, EG output looks like so:
> 1..Player Teleported
> 2..Player Teleported
~XlAscensionlX [Graphic Design://Scripter://Developer://] |
|
drahsid5Join Date: 2011-05-13 Post Count: 3937 |
Do not post code blocks, tell us you're problem, what you're trying to accomplish, and what you've tried. |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
I haven't completely looked through the code, but the problem I immediately spotted was:
"or player.TeamColor == "Bright yellow"
You probably meant to do == BrickColor.new("Bright yellow") |
|
|
@drahsid5, I am posting code blocks so you dont go throught a ton of lines of code to find the problem, I posted the relevant code, i'm trying to make it so the table always updates correctly (EG if theres one player in game then the tables only has 1 player in it) and it keeps saying there's 2.
~XlAscensionlX [Graphic Design://Scripter://Developer://] |
|
|
Bump
~XlAscensionlX [Graphic Design://Scripter://Developer://] |
|
|
1
~XlAscensionlX [Graphic Design://Scripter://Developer://] |
|
|
2
~XlAscensionlX [Graphic Design://Scripter://Developer://] |
|
|
3
~XlAscensionlX [Graphic Design://Scripter://Developer://] |
|
|
Well, when the game restarts just make the Survivor table empty.
If money grew on trees... It would be as valuable as leaves. | Twitter: @TwisterRBLX
|
|
|
@twister1976,
I do, but however when it teleports them anytime after the first time it think it's teleporting 2 players
~XlAscensionlX [Graphic Design://Scripter://Developer://] |
|
|
You are using or incorrectly.
You have
if ((x == y) or z) then
end
And what you want is
if ((x == y) or (x == z)) then
end |
|
|
if player.TeamColor == BrickColor.new("Bright bluish green") or player.TeamColor == ("Bright yellow") then
end
^^
What's wrong with that?
~XlAscensionlX [Graphic Design://Scripter://Developer://] |
|
TimeTicksJoin Date: 2011-04-27 Post Count: 27115 |
local alive = {}
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(char)
char.Humanoid.Died:connect(function()
if player.TeamColor == BrickColor.new("Bright bluish green") then
player.TeamColor = BrickColor.new("Bright blue")
for i,v in next, alive do
if v == player.Name then
table.remove(alive,i)
end
end
end
end)
end)
end)
|
|
|
THANK YOU SO MUCH
~XlAscensionlX [Graphic Design://Scripter://Developer://] |
|