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
 

Re: Raid System help

Previous Thread :: Next Thread 
iiFirestorm is not online. iiFirestorm
Joined: 19 Dec 2012
Total Posts: 2374
06 Feb 2015 04:53 PM
So I'm scripting a raiding system, that updates constantly but I'm running into an issue. It keeps up-to-date on how many players are on a team, however when the last one leaves, or his team changes, it doesn't go to 0. I've looked into lighting where "Hostiles" and "Imperial" are located, and they both equal one whenever I manually change my team. They just won't go lower and I need a work around.

This ALSO happens when you use admin to change an entire team to another team, the team they were changed FROM doesn't change numbers or update at all, but the team they're changed to does.

Code:

function update1a()
--Is Official

local plrs = game.Players:GetPlayers()
for i=1, #plrs do
plrs[i].PlayerGui.RaidGui.Main.RaidCounter.RaidStatus.Label3.Text = "Official"
plrs[i].PlayerGui.RaidGui.Main.RaidCounter.RaidStatus.Label3.TextColor3 = Color3.new(255/255, 0, 0)
plrs[i].PlayerGui.RaidGui.Main.RaidCounter.RaidTime.Label4.Script.Value.Value = true
_G.Official = true
end
end

function update2a()
--Unofficial
local plrs = game.Players:GetPlayers()
for i=1, #plrs do
plrs[i].PlayerGui.RaidGui.Main.RaidCounter.RaidStatus.Label3.Text = "Unofficial"
plrs[i].PlayerGui.RaidGui.Main.RaidCounter.RaidStatus.Label3.TextColor3 = Color3.new(255/255, 255/255, 255/255)
plrs[i].PlayerGui.RaidGui.Main.RaidCounter.RaidTime.Label4.Script.Value.Value = false
_G.Official = false
plrs[i].PlayerGui.RaidGui.Main.RaidCounter.RaidTime.Label4.Text = "5400"
end
end


function update1b()
local plrs = game.Players:getPlayers()
for i=1, #plrs do
a=0
b=0
if plrs[i].TeamColor == game.Teams[home].TeamColor then
a=a + 1
elseif plrs[i].TeamColor == game.Teams[enemy].TeamColor then
b=b + 1
end
end
end


enemy = "Raiders"
home = "Imperials"
ally = "The Blades"
while true do
wait()
local players = game.Players:getPlayers()
hometeam = 0
enemies = 0
if #players >= 1 then
for i = 1, #players do
if players[i].TeamColor == game.Teams[enemy].TeamColor then
enemies = enemies + 1
game.Lighting.Hostiles.Value = enemies
elseif players[i].TeamColor == game.Teams[home].TeamColor or players[i].TeamColor == game.Teams[ally].TeamColor then
hometeam = hometeam + 1
game.Lighting.Imperial.Value = hometeam
end
end
end
if hometeam >= 6 and enemies >= 6 then --Determines if there's enough on each team.
update1a()
update1b()
else
update2a()
update1b()
end
end

while true do
wait()
local players = game.Players:getPlayers()
if #players >= 1 then
for i = 1, #players do
if hometeam == 1 and (players[i].TeamColor ~= game.Teams[home] and players[i].TeamColor ~= game.Teams[ally]) then
game.Lighting.Imperial.Value = 0
if enemies == 1 and players[i].TeamColor ~= game.Teams[enemy] then
game.Lighting.Hostiles.Value = 0
end
end
end
end
end
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
06 Feb 2015 04:57 PM
"while true do
wait()"
Lol, you should never run that bad of a loop 30 times per second. Change it to 1 second.
Report Abuse
ChoongJae is not online. ChoongJae
Joined: 10 Oct 2009
Total Posts: 670
06 Feb 2015 05:02 PM
hi firestorm

I'm pretty sure the 2nd while true do loop will never run because the 1st run is taking up the thread (i think that's how you're supposed to say it)

It might be a good idea to go ahead and integrate the 2nd loop with the first loop. In both loops, you're getting all the players and looping through them to check their teams anyways, so try to combine them.

and yeah, looping through the players and checking all that every 1/30th of a second isn't exactly great
Report Abuse
iiFirestorm is not online. iiFirestorm
Joined: 19 Dec 2012
Total Posts: 2374
06 Feb 2015 05:15 PM
Got anything for my actual problem?

I do thank you for the advice, but I still have a problem here :)
Report Abuse
iiFirestorm is not online. iiFirestorm
Joined: 19 Dec 2012
Total Posts: 2374
06 Feb 2015 07:58 PM
bump pls.

i need halp
Report Abuse
iiFirestorm is not online. iiFirestorm
Joined: 19 Dec 2012
Total Posts: 2374
07 Feb 2015 12:41 PM
bumppp
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