|
| 15 Sep 2015 09:15 PM |
game.Players.Player1.CharacterAdded:connect(function(Character) Character.Humanoid.Died:connect(function() for Index, Player in pairs(p) do if Player == game.Players:GetPlayerFromCharacter(Character) then table.remove(p, Index) end end end) end)
Focus on the first line. How do I change Player1 to ALL the players?
Yes this is a repost because a helpful post by XIIGhostIIX didn't work. |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:20 PM |
= game.Players.CharacterAdded:connect(function(Character) Character.Humanoid.Died:connect(function() for Index, Player in pairs(p) do if Player == game.Players:GetPlayerFromCharacter(Character) then table.remove(p, Index) end end end) end)
Sorry if doesn't work. |
|
|
| Report Abuse |
|
|
Sevrick
|
  |
| Joined: 22 Oct 2013 |
| Total Posts: 3846 |
|
| |
|
|
| 15 Sep 2015 09:21 PM |
Also don't add the weird ''='' thing i put in there.
|
|
|
| Report Abuse |
|
|
| |
|
Sevrick
|
  |
| Joined: 22 Oct 2013 |
| Total Posts: 3846 |
|
| |
|
| |
|
|
| 15 Sep 2015 09:23 PM |
| It won't work because CharacterAdded is not a child of Players |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:24 PM |
| Can you post the entire script? |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:25 PM |
| Alright, what is it that you are trying to do in your script? |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:25 PM |
| Child added is not a member of a player lol? Only player or other instances? |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:26 PM |
dennis it's the script you gave me:
game.Players.CharacterAdded:connect(function(Character) Character.Humanoid.Died:connect(function() for Index, Player in pairs(p) do if Player == game.Players:GetPlayerFromCharacter(Character) then table.remove(p, Index) print(#p) end end end) end)
Didn't work exactly because aren't we specifying Player1? |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:27 PM |
What I'm trying to do is detecting when ANY player dies and then removing them from the p table. I have scripted the code for adding players into table p, which is this:
for _, Player in pairs(game.Players:GetPlayers()) do table.insert(p, Player) print(#p) end |
|
|
| Report Abuse |
|
|
Sevrick
|
  |
| Joined: 22 Oct 2013 |
| Total Posts: 3846 |
|
|
| 15 Sep 2015 09:27 PM |
Read over the wiki again.
http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Died |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:28 PM |
| You were supposed to modify it to fit your need, like using it with the Players.PlayerAdded event. I just used Player1 as an example. |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 Sep 2015 09:29 PM |
Ahh, thanks. So, therefore this is the script?
game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() for Index, Player in pairs(p) do if Player == game.Players:GetPlayerFromCharacter(character) then table.remove(p, Index) print(#p) end end end) end) end) |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:30 PM |
| Yeah sorry dennis, I'm a noob scripter so I didn't understand :P |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:30 PM |
| Wait, do you add the players back to the table when they respawn? |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:31 PM |
Um, does this script do that?
for _, Player in pairs(game.Players:GetPlayers()) do table.insert(p, Player) print(#p) end |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:33 PM |
| No, that only runs once. What are you using the table of players for, exactly? |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:34 PM |
| I'm making a minigame where every 15 seconds a player dies, and I want to see when there is one last player alive. |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:36 PM |
Every 15?
Wait (15)
function waitForChild(parent, instance) while parent:FindFirstChild(instance) == nil do --print(parent .. "waiting" .. instance) wait() end end
local debris = game:GetService("Debris")
waitForChild(game, "Teams") waitForChild(script, "Time Remaining") waitForChild(script, "Regening") waitForChild(script, "Winners") waitForChild(script, "IntroScreen") waitForChild(script, "Announcement") waitForChild(script, "Round Duration") waitForChild(game.Workspace, "CapturePointsModel") waitForChild(script, "PlayerAddedVal") waitForChild(script, "PlayerRemovedVal") waitForChild(script, "TriggerVictoryScreen") waitForChild(script, "Feed") waitForChild(script, "MVP") waitForChild(script, "FreezeCharacters") waitForChild(script, "CaptureFeed") waitForChild(game.Workspace, "BlueSpawnParts") waitForChild(game.Workspace, "RedSpawnParts") waitForChild(game.Workspace, "Diagnostics")
local remainingTime = script["Time Remaining"] local roundDuration = script["Round Duration"] if remainingTime then remainingTime.Value = roundTime end local regening = script["Regening"] local winners = script.Winners local introScreen = script.IntroScreen local announcement = script.Announcement local playerAddedVal = script.PlayerAddedVal local playerRemovedVal = script.PlayerRemovedVal local triggerVictoryScreen = script.TriggerVictoryScreen local killFeed = script.Feed local MVP = script.MVP local freezeCharacters = script.FreezeCharacters local captureFeed = script.CaptureFeed local diagnostics = game.Workspace.Diagnostics
local myGame = {} myGame.NumPlayers = 0 myGame.GameTime = roundDuration.Value myGame.MinPlayers = 1 myGame.Regening = false myGame.PlayerScores = {}
myGame.TeamCount = {} myGame.Teams = {} myGame.TeamScores = {} myGame.Appearance = {}
myGame["BlueTeamCharacter"] = {"http://www.roblox.com/Asset/CharacterFetch.ashx?userId=22931356"} myGame["RedTeamCharacter"] = {"http://www.roblox.com/Asset/CharacterFetch.ashx?userId=22931253"}
local debug = Instance.new("StringValue") debug.Name = "Debug" debug.Parent = game.Workspace debug.Value = "Debugging"
local teamsInPlace = game.Teams:GetChildren() for i = 1, #teamsInPlace do table.insert(myGame.Teams, teamsInPlace[i]) local teamScore = Instance.new("IntValue") teamScore.Name = teamsInPlace[i].Name .. "TeamCaptures" teamScore.Parent = script teamScore.Value = 0 myGame.TeamScores[teamsInPlace[i]] = teamScore.Value end
local badgeService = game:GetService("BadgeService")
myGame.CapturePoints = {} local capturePointsModel= game.Workspace.CapturePointsModel
function populateCapturePointsTable(cp) if not cp then local capturePointsInWorkspace = capturePointsModel:GetChildren() for i = 1, #capturePointsInWorkspace do if capturePointsInWorkspace[i] and capturePointsInWorkspace[i].Value then table.insert(myGame.CapturePoints, capturePointsInWorkspace[i].Value) local cpStatus = Instance.new("IntValue") cpStatus.Name = capturePointsInWorkspace[i].Value.Name .. "Status" cpStatus.Value = 0 cpStatus.Parent = script end end else while cp.Value == nil do wait() print("Waiting on CP value") end table.insert(myGame.CapturePoints, cp.Value) local cpStatus = Instance.new("IntValue") cpStatus.Name = cp.Value.Name .. "Status" cpStatus.Value = 0 cpStatus.Parent = script end end
populateCapturePointsTable() capturePointsModel.ChildAdded:connect(populateCapturePointsTable)
local badgeList = {} badgeList["Curly"] = 75871975 badgeList["Moe"] = 75872137 badgeList["Larry"] = 75872077 badgeList["MVP"] = 75872284
for i = 1, #myGame.CapturePoints do print(myGame.CapturePoints[i].Name) end
local msg = Instance.new("Message") msg.Parent = game.Workspace msg.Text = ""
if debug then debug.Value = "Variables done" end
function myGame:CreateFloatingIcon(pos, icon, suspension, speed) local p = Instance.new("Part") p.Name = "FloatingPoint" p.FormFactor = "Custom" p.Size = Vector3.new(0.2, 0.2, 0.2) p.Transparency = 1 p.CanCollide = false p.CFrame = CFrame.new(pos)
local bf = Instance.new("BodyForce") bf.force = Vector3.new(0, speed * (196.0 * p:GetMass()), 0)
local bbGui = Instance.new("BillboardGui") bbGui.Size = UDim2.new(3, 0, 2, 0) bbGui.Adornee = p local imageLabel = Instance.new("ImageLabel") imageLabel.Size = UDim2.new(1.5, 0, 1, 0) imageLabel.BackgroundTransparency = 1 imageLabel.Image = icon
imageLabel.Parent = bbGui bbGui.Parent = p bf.Parent = p p.Parent = game.Workspace debris:AddItem(p, suspension) end
function myGame:GenerateMoney(pos) for i = 1, math.random(10, 14) do local buck = Instance.new("Part") buck.formFactor = 2 buck.Size = Vector3.new(2, 0.4, 1) buck.BrickColor = BrickColor.new(28) buck.TopSurface = 0 buck.BottomSurface = 0 buck.Elasticity = .01 buck.CanCollide = false
local d = Instance.new("Decal") d.Face = 4 d.Texture = "http://www.roblox.com/asset/?id=16658163" d.Parent = buck
local d2 = d:Clone() d2.Face = 1 d2.Parent = buck
buck.Parent = game.Workspace
buck.CFrame = CFrame.new(pos + Vector3.new(math.random(), 1, math.random()) )
buck.Velocity = Vector3.new(math.random(), 100, math.random())
debris:AddItem(buck, 4.5) wait(0.25) end end
function myGame:Update() local count = 0 while myGame.Teams[1] and myGame.Teams[2] and myGame.Teams[1].Score < 830000 and myGame.Teams[2].Score < 830000 do local duration = 5 for i = 1, duration do myGame.GameTime = myGame.GameTime + 1 if remainingTime then remainingTime.Value = myGame.GameTime end wait(1) end for i = 1, #myGame.CapturePoints do local teamColor = "" if myGame.CapturePoints[i]:FindFirstChild("Highlight") and myGame.CapturePoints[i].Highlight:FindFirstChild("Mesh") and myGame.CapturePoints[i]:FindFirstChild("ColorPad") then for j = 1, #myGame.Teams do if tostring(myGame.CapturePoints[i].Highlight.BrickColor) == tostring(myGame.Teams[j].TeamColor) then if tostring(myGame.Teams[j].TeamColor) == "Bright red" then myGame:CreateFloatingIcon(myGame.CapturePoints[i].ColorPad.Position + Vector3.new(0, 5, 0), "http://www.roblox.com/asset/?id=75930682", 2.5, 1.025) if script:FindFirstChild(myGame.CapturePoints[i].Name .. "Status") then script[myGame.CapturePoints[i].Name .. "Status"].Value = 1 teamColor = "Bright red" end else myGame:CreateFloatingIcon(myGame.CapturePoints[i].ColorPad.Position + Vector3.new(0, 5, 0), "http://www.roblox.com/asset/?id=75930626", 2.5, 1.025) if script:FindFirstChild(myGame.CapturePoints[i].Name .. "Status") then script[myGame.CapturePoints[i].Name .. "Status"].Value = 2 teamColor = "Bright blue" end end myGame.Teams[j].Score = myGame.Teams[j].Score + 3000 myGame.TeamScores[myGame.Teams[j]] = myGame.TeamScores[myGame.Teams[j]] + 3000 end end end if _G["CapturePointsTable"][myGame.CapturePoints[i]] then -- UNFORTUNATE HACK REALITY -- local captureFeedString = teamColor .. "-" local foundAtleastOnePlayer = false for index, player in pairs(_G["CapturePointsTable"][myGame.CapturePoints[i]]) do captureFeedString = captureFeedString .. player.Name .. "," foundAtleastOnePlayer = true local cpPos = myGame.CapturePoints[i].ColorPad.Position coroutine.resume(coroutine.create(function() myGame:GenerateMoney(cpPos) end)) coroutine.resume(coroutine.create(function() if teamColor and cpPos then wait(0.75) if teamColor == "Bright red" then myGame:CreateFloatingIcon(cpPos + Vector3.new(0, 5, 0), "http://www.roblox.com/asset/?id=75930725", 4.5, 1.025) else myGame:CreateFloatingIcon(cpPos + Vector3.new(0, 5, 0), "http://www.roblox.com/asset/?id=75930710", 4.5, 1.025) end end end)) end if captureFeed and captureFeedString ~= "-" and foundAtleastOnePlayer then --captureFeed.Value = "" --wait() captureFeed.Value = captureFeedString end if teamColor and foundAtleastOnePlayer then for a = 1, #myGame.Teams do if myGame.Teams[a].TeamColor == BrickColor.new(teamColor) then myGame.Teams[a].Score = myGame.Teams[a].Score + 15000 myGame.TeamScores[myGame.Teams[a]] = myGame.TeamScores[myGame.Teams[a]] + 15000 end end end ------------------------------ for index, player in pairs(_G["CapturePointsTable"][myGame.CapturePoints[i]]) do if myGame.PlayerScores[player] then myGame.PlayerScores[player] = myGame.PlayerScores[player] + 3000 else myGame.PlayerScores[player] = 3000 end if player:FindFirstChild("leaderstats") then if player.leaderstats:FindFirstChild("Score") then player.leaderstats.Score.Value = player.leaderstats.Score.Value + 3000 end if player.leaderstats:FindFirstChild("Captures") then player.leaderstats.Captures.Value = player.leaderstats.Captures.Value + 1 end end end end _G["CapturePointsTable"][myGame.CapturePoints[i]] = {} -- Null the table! end end end
function myGame:ShuffleTeams() myGame.TeamCount = {} for i = 1, #myGame.Teams do if myGame.Teams[i] then myGame.TeamCount[myGame.Teams[i]] = 0 print(myGame.TeamCount[myGame.Teams[i]]) end end
local players = game.Players:GetChildren() local count = 1 local numberOfPlayers = #players while myGame.TeamCount[myGame.Teams[1]] < numberOfPlayers/2 and count <= numberOfPlayers do tick() if (math.random(1, 2)== 1 or myGame.TeamCount[myGame.Teams[2]] > numberOfPlayers/2) then if players[count] then myGame.TeamCount[myGame.Teams[1]] = myGame.TeamCount[myGame.Teams[1]] + 1 players[count].TeamColor = myGame.Teams[1].TeamColor if myGame[myGame.Teams[1].Name .. "TeamCharacter"] then players[count].CharacterAppearance = myGame[myGame.Teams[1].Name .. "TeamCharacter"][1] end end else if players[count] then myGame.TeamCount[myGame.Teams[2]] = myGame.TeamCount[myGame.Teams[2]] + 1 players[count].TeamColor = myGame.Teams[2].TeamColor if myGame[myGame.Teams[2].Name .. "TeamCharacter"] then players[count].CharacterAppearance = myGame[myGame.Teams[2].Name .. "TeamCharacter"][1] end end end count = count + 1 end for i = count, numberOfPlayers do if players[i] then myGame.TeamCount[myGame.Teams[2]] = myGame.TeamCount[myGame.Teams[2]] + 1 players[i].TeamColor = myGame.Teams[2].TeamColor if myGame[myGame.Teams[2].Name .. "TeamCharacter"] then players[count].CharacterAppearance = myGame[myGame.Teams[2].Name .. "TeamCharacter"][1] end end end end
if debug then debug.Value = "Update" end
function myGame:Regen() if debug then debug.Value = "Regening" end local duration = 8 myGame.Regening = true if regening then regening.Value = true end
myGame:ShuffleTeams()
for i = duration, 1, -1 do msg.Text = "Next round starts in " .. i .. " seconds" end msg.Text = " " if roundDuration then myGame.GameTime = roundDuration.Value end myGame.PlayerScores = {} players = game.Players:GetChildren() for i = 1, #players do if players[i] and players[i]:FindFirstChild("leaderstats") and players[i].leaderstats:FindFirstChild("Score") then players[i].leaderstats.Score.Value = 0 myGame.PlayerScores[players[i]] = 0 end end for i = 1, #myGame.Teams do myGame.Teams[i].Score = 0 end wait(2.0) if announcement then announcement.Value = "" end if debug then debug.Value = "Regen done" end if MVP then MVP.Value = nil end
local players = game.Players:GetChildren()
for i = 1, #myGame.CapturePoints do if myGame.CapturePoints[i] then local cpStatus = script:FindFirstChild(myGame.CapturePoints[i].Name .. "Status") if cpStatus then cpStatus.Value = 0 end end end for i = 1, #players do if players[i] and players[i].Character then players[i].Character:BreakJoints() end end end
function myGame:AwardBadges(mvpPlayer, winningTeam) if mvpPlayer then badgeService:AwardBadge(mvpPlayer.userId, badgeList["MVP"]) end
local players = game.Players:GetPlayers()
for i = 1, #players do if players[i] and players[i]:FindFirstChild("CName") and winningTeam and players[i].TeamColor == winningTeam.TeamColor then badgeService:AwardBadge(players[i].userId, badgeList[players[i].CName.Value]) end end end
function myGame:Start() if debug then debug.Value = "In Start" end local count = - 1 local players = game.Players:GetChildren() for i = 1, #myGame.Teams do myGame.Teams[i].Score = 0 end for i = 1, #players do if players[i]:FindFirstChild("leaderstats") == nil then local leaderstats = Instance.new("IntValue") leaderstats.Parent = players[i] leaderstats.Name = "leaderstats" local score = Instance.new("IntValue") score.Parent = leaderstats score.Name = "Score" score.Value = 0 local captures = Instance.new("IntValue") captures.Parent = leaderstats captures.Name = "Captures" captures.Value = 0 else if players[i].leaderstats:FindFirstChild("Captures") then players[i].leaderstats.Captures.Value = 0 end if players[i].leaderstats:FindFirstChild("Score") then players[i].leaderstats.Score.Value = 0 end end end while #game.Players:GetChildren() < myGame.MinPlayers do players = game.Players:GetChildren() for i = 1, #players do if players[i] and players[i].Character and players[i].Character:FindFirstChild("Humanoid") then if freezeCharacters then --players[i].Character.Humanoid.WalkSpeed = 0.0 freezeCharacters.Value = true end end end if msg then if count > 0 then msg.Text = "Waiting for ".. (myGame.MinPlayers - #game.Players:GetChildren()) .. " more player(s)" else msg.Text = "" end count = count * -1 end wait(1) end if introScreen then introScreen.Value = true end wait(5.0) if introScreen then introScreen.Value = false end msg.Text = "BEGIN!" wait(1.5) msg.Text = "" myGame.Regening = false if regening then regening.Value = false end local players = game.Players:GetChildren() for i = 1, #players do if players[i] and players[i].Character and players[i].Character:FindFirstChild("Humanoid") and players[i].Character:FindFirstChild("Torso") then if players[i] then players[i].Character.Torso.Anchored = false end --if players[i] then players[i].Character.Humanoid.WalkSpeed = 30.0 end if freezeCharacters then freezeCharacters.Value = false end end end myGame:Update() -- This occurs for the entire round duration if msg then msg.Text = "Round Over" wait(1.0) msg.Text = " " end myGame.Regening = true local players = game.Players:GetChildren() for i = 1, #players do if players[i] and players[i].Character and players[i].Character:FindFirstChild("Humanoid") then --players[i].Character.Humanoid.WalkSpeed = 0.0 if freezeCharacters then freezeCharacters.Value = false freezeCharacters.Value = true end end end local winningTeam = nil local winningScore = 0 if winners then for team, teamScore in pairs(myGame.TeamScores) do if teamScore > winningScore then winningTeam = team winningScore = teamScore end end if winningTeam and winningScore then local thereIsATie = false for team, teamScore in pairs(myGame.TeamScores) do if teamScore == winningScore and team ~= winningTeam then thereIsATie = true end end if not thereIsATie then --msg.Text = "The winners are " .. winningTeam.Name else --msg.Text = "NOBODY WON" winningTeam = nil end end --msg.Text = "" end if debug then debug.Value = "Awarding MVP" end local max = 0 local mvpPlayer = nil --if #game.Players:GetChildren() >= 10 then for i, v in pairs (myGame.PlayerScores) do if v > max then mvpPlayer = i max = v else if v == max then if v ~= 0 and game.Workspace:FindFirstChild("MVP") then game.Workspace.MVP.Value = "Two people had the same score" .. v end mvpPlayer = nil end end end if mvpPlayer then if MVP then MVP.Value = mvpPlayer end else if game.Workspace:FindFirstChild("MVP") then game.Workspace.MVP.Value = "NO MVP" end end if debug then debug.Value = "Awarded MVP" end
myGame:AwardBadges(mvpPlayer, winningTeam) --end if triggerVictoryScreen then triggerVictoryScreen.Value = true end wait(20.0) if triggerVictoryScreen then triggerVictoryScreen.Value = false end
-- Regen the round now myGame:Regen() myGame:Start() end
if debug then debug.Value = "After Start" end
-- NEED TO CLEAN THIS FUNCTION -- function myGame:CountScore(humanoid) if humanoid then local woPlayer = game.Players:GetPlayerFromCharacter(humanoid.Parent) local tag = humanoid:FindFirstChild("creator") if tag and tag.Value then local player = tag.Value if player and player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Score") then if woPlayer and player == woPlayer then player.leaderstats.Score.Value = player.leaderstats.Score.Value - 1000 else player.leaderstats.Score.Value = player.leaderstats.Score.Value + 1000 end end if myGame.PlayerScores[player] then if woPlayer and player == woPlayer then myGame.PlayerScores[player] = myGame.PlayerScores[player] - 1000 else myGame.PlayerScores[player] = myGame.PlayerScores[player] + 1000 end else if woPlayer and player and player == woPlayer then myGame.PlayerScores[player] = - 1000 else myGame.PlayerScores[player] = 1000 end end if player and player:IsA("Player") then for i = 1, #myGame.Teams do if tostring(player.TeamColor) == tostring(myGame.Teams[i].TeamColor) then print("Scoring") myGame.Teams[i].Score = myGame.Teams[i].Score + 1000 myGame.TeamScores[myGame.Teams[i]] = myGame.Teams[i].Score end end if woPlayer and killFeed then waitForChild(tag, "WeaponTag") print("found tag") killFeed.Value = player.Name .. "-" .. woPlayer.Name .. "," .. tag.WeaponTag.Value end end end end end
function myGame:DressPlayerCharacter(character, teamColor, player) if player and character and teamColor then if tostring(teamColor) == "Bright blue" then player.CharacterAppearance = myGame["BlueTeamCharacter"][1] else player.CharacterAppearance = myGame["RedTeamCharacter"][1] end
coroutine.resume(coroutine.create(function() --[[local shirtAssets = {} shirtAssets["Assault"] = {72048056, 72048067} shirtAssets["Trooper"] = {72048086, 72048096} shirtAssets["Brute"] = {72048110, 72048123} shirtAssets["Support"] = {72048145, 72048150} shirtAssets["Sniper"] = {72048160, 72048163}
waitForChild(character, "Shirt") while tostring(player.TeamColor) ~= "Bright blue" and tostring(player.TeamColor) ~= "Bright red" do wait() end
waitForChild(player, "CName") local className = player.CName if className and className.Value and shirtAssets[className.Value] then if tostring(player.TeamColor) == "Bright blue" then character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=" .. shirtAssets[className.Value][1] else character.Shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=" .. shirtAssets[className.Value][2] end end]]
end)) end end
game.Players.PlayerAdded:connect(function(newPlayer) -------------------------HAAAAAAAAAAAAAAX----------------------------- if newPlayer:FindFirstChild("ShowIntro") == nil then local showIntro = Instance.new("BoolValue") showIntro.Name = "ShowIntro" showIntro.Value = true showIntro.Parent = newPlayer end -------------------------END HAAAAAAAAAAAAAAX-------------------------
local players = game.Players:GetChildren() myGame.TeamCount = {} for i = 1, #myGame.Teams do if myGame.Teams[i] then myGame.TeamCount[myGame.Teams[i]] = 0 print(myGame.TeamCount[myGame.Teams[i]]) end end for i = 1, #players do for team, _ in pairs(myGame.TeamCount) do if players[i].TeamColor == team.TeamColor then myGame.TeamCount[team] = myGame.TeamCount[team] + 1 end end end for team, num in pairs(myGame.TeamCount) do print(team, num) end local teamWithMinPlayersColor = nil local teamCount = math.huge for team, count in pairs(myGame.TeamCount) do if count < teamCount then teamCount = count teamWithMinPlayers = team end end if teamWithMinPlayers then newPlayer.TeamColor = teamWithMinPlayers.TeamColor myGame.TeamCount[teamWithMinPlayers] = myGame.TeamCount[teamWithMinPlayers] + 1 end newPlayer.CharacterAdded:connect(function(character) waitForChild(character, "Humanoid") local thisHumanoid = character.Humanoid character.Humanoid.Died:connect(function() myGame:CountScore(character.Humanoid) if character then local charChildren = character:GetChildren() for i = 1, #charChildren do if charChildren[i] and (charChildren[i]:IsA("BasePart") or charChildren[i]:IsA("Hat")) then charChildren[i]:Destroy() end end end end) --myGame:DressPlayerCharacter(character, newPlayer.TeamColor, newPlayer) waitForChild(character, "Torso") local thisTorso = character.Torso local teamColor = tostring(newPlayer.TeamColor) if newPlayer and newPlayer:FindFirstChild("ShowIntro") and newPlayer.ShowIntro.Value == true then -- Do nothing --print("Found him") else --[[if teamColor == "Bright blue" then local bCh = game.Workspace.BlueSpawnParts:GetChildren() local eww = bCh[math.random(1, #bCh)].CFrame + Vector3.new(0, 5, 0) while character.Torso.CFrame ~= CFrame.new(eww.p) do --+ Vector3.new(0, 5, 0) character.Torso.CFrame = CFrame.new(eww.p) wait() end else local rCh = game.Workspace.RedSpawnParts:GetChildren() local eww = rCh[math.random(1, #rCh)].CFrame + Vector3.new(0, 5, 0) while character.Torso.CFrame ~= CFrame.new(eww.p) do character.Torso.CFrame = CFrame.new(eww.p) wait() end end ]] end if myGame.Regening then --thisHumanoid.WalkSpeed = 0.0 if freezeCharacters then freezeCharacters.Value = true end end
while newPlayer:FindFirstChild("Health") == nil or newPlayer:FindFirstChild("Speed") == nil do wait() end
if thisHumanoid then thisHumanoid.WalkSpeed = newPlayer.Speed.Value thisHumanoid.MaxHealth = newPlayer.Health.Value while thisHumanoid.Health ~= newPlayer.Health.Value do thisHumanoid.Health = newPlayer.Health.Value wait() end end
if newPlayer and character and not character:FindFirstChild("Stoogified") then waitForChild(character, "Torso") waitForChild(newPlayer, "CName") local cName = newPlayer.CName while character.Parent == nil do wait() end local initPos = character.Torso.Position if game.Lighting[cName.Value] then local newCharacter = game.Lighting[cName.Value]:Clone() newCharacter.ChildAdded:connect(function(child) if not child:IsA("Tool") and not child:IsA("BoolValue") then child:Destroy() end end) if newCharacter:FindFirstChild("Head") then newCharacter.Head.ChildAdded:connect(function(child) if child:IsA("DataModelMesh") and newCharacter and newCharacter.Head then child:Destroy() local mesh = Instance.new("SpecialMesh") mesh.Parent = newCharacter.Head mesh.Scale = Vector3.new(1.2, 1.2, 1.2) while newCharacter.Head.BrickColor ~= BrickColor.new("Nougat") do print("Setting head") newCharacter.Head.BrickColor = BrickColor.new("Nougat") end end if child:IsA("Decal") and cName then print("Setting face") if cName.Value == "Moe" then child.Texture = "http://www.roblox.com/asset/?id=31117192" elseif cName.Value == "Curly" then child.Texture = "http://www.roblox.com/asset/?id=7046286" else child.Texture = "http://www.roblox.com/asset/?id=21635489" end end end) end newCharacter.Name = character.Name newPlayer.Character = newCharacter newPlayer.Character.Parent = game.Workspace newPlayer.Character:MoveTo(initPos) if character then print("Destroying") character:Destroy() end character = newPlayer.Character end end end)
-- leaderstats if newPlayer:FindFirstChild("leaderstats") == nil then local leaderstats = Instance.new("IntValue") leaderstats.Parent = newPlayer leaderstats.Name = "leaderstats" local score = Instance.new("IntValue") score.Parent = leaderstats score.Name = "Score" score.Value = 0
local captures = Instance.new("IntValue") captures.Parent = leaderstats captures.Name = "Captures" captures.Value = 0 local haxStr = Instance.new("StringValue") haxStr.Parent = leaderstats end
while newPlayer.Character == nil do wait() end while newPlayer.Character:FindFirstChild("Torso") == nil do wait() end while newPlayer.Character:FindFirstChild("Humanoid") == nil do wait() end
if newPlayer:FindFirstChild("CName") == nil then local stooges = {"Moe", "Larry", "Curly"}
local className = Instance.new("StringValue") className.Name = "CName" className.Value = stooges[math.random(1, #stooges)] className.Parent = newPlayer
local health = Instance.new("IntValue") health.Name = "Health" health.Value = 100 health.Parent = newPlayer
local speed = Instance.new("IntValue") speed.Name = "Speed" speed.Value = 20 speed.Parent = newPlayer end
if playerAddedVal then playerAddedVal.Value = newPlayer end if newPlayer.Character then --newPlayer.Character:BreakJoints() end
if newPlayer.CameraMode then --newPlayer.CameraMode = Enum.CameraMode.LockFirstPerson end --
while newPlayer.Character:FindFirstChild("Stoogified") == nil do wait() end local charChildren = newPlayer.Character:GetChildren() for i = 1, #charChildren do if charChildren[i] then if charChildren[i]:IsA("BasePart") then charChildren[i].Transparency = 1.0 charChildren[i].Anchored = true elseif charChildren[i]:IsA("Humanoid") then charChildren[i].WalkSpeed = 0.0 elseif charChildren[i]:IsA("Hat") then charChildren[i]:Destroy() end if charChildren[i].Name == "Head" then waitForChild(charChildren[i], "face") charChildren[i].face.Transparency = 1.0 end end end
end)
game.Players.PlayerRemoving:connect(function(player) if playerRemovedVal then playerRemovedVal.Value = player end myGame.NumPlayers = #game.Players:GetChildren() if myGame.PlayerScores[player] then myGame.PlayerScores[player] = nil end for teamColor, count in pairs(myGame.TeamCount) do if tostring(player.TeamColor) == tostring(teamColor) then myGame.TeamCount[teamColor] = myGame.TeamCount[teamColor] - 1 end end end)
coroutine.resume(coroutine.create(function() end))
myGame:Start() -- Seed it! if debug then debug.Value = "All over" end |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:36 PM |
| Why don't you do this: under the Player.CharacterAdded event, add them to the table, but under the Humanoid.Died event, remove them from the table. |
|
|
| Report Abuse |
|
|
|
| 15 Sep 2015 09:38 PM |
1. Epicface, HOWD YOU SCRIPT THAT IN 5 MINUTES??!/?1?1?1?1!111!/1?
2. Dennis, sure I'll try that.
|
|
|
| Report Abuse |
|
|