generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Where should I put this script?

Previous Thread :: Next Thread 
Contouri is not online. Contouri
Joined: 07 Oct 2011
Total Posts: 2792
10 Jul 2015 04:24 AM
local teams = {red = BrickColor.Red(), blue = BrickColor.Blue()}

local function GetTeamInfo(TeamColor)
local Count = 0
local Players = {}
for Index, Player in next, game:GetService("Players"):GetPlayers() do
local Color = Player.TeamColor
if Color == TeamColor then
Count = Count + 1
table.insert(Players, Player)
end
end
return {count = Count, players = Players}
end

function applyHealth(greater, less)
for _, player in pairs(less.players) do
if player.Character:FindFirstChild("Humanoid") then
player.Character.Humanoid.MaxHealth = 100 + ((greater.count - less.count) * 5)
end
end
end

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
local redInfo = GetTeamInfo(teams.red)
local blueInfo = GetTeamInfo(teams.blue)
if redInfo.count > blueInfo.count then
applyHealth(redInfo, blueInfo)
elseif blueInfo.count > redInfo.count then
applyHealth(blueInfo, redInfo)
else
for _, player in pairs(game.Players:GetPlayers()) do
if player.Character:FindFirstChild("Humanoid") then
player.Character.Humanoid.MaxHealth = 100
end
end
end
end)
end)
Report Abuse
Trastercraft is not online. Trastercraft
Joined: 11 Aug 2013
Total Posts: 103
10 Jul 2015 06:37 AM
ServerScriptService?
Report Abuse
WolfgangVonPrinz is not online. WolfgangVonPrinz
Joined: 24 Oct 2013
Total Posts: 4656
10 Jul 2015 08:12 AM
What does it do? I think it should be a global script.

▲☭⎊▲Obama is a giant overlord space lizard▲⎊☭▲
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image