devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 09 Sep 2014 09:04 PM |
Hey scripters,
I am trying to make a script to team everyone from the spectators team to either the "Noobs" or "Guests" team. Also, I am trying to make a minimum of 1 player on each team and a maximum of 4 on the "Noobs" team and I need to make sure when this function is ran that there are no players allowed on the "Spectators" team.
Thanks and please post any help below!
|Seems legit | devTools |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 09 Sep 2014 09:14 PM |
And what do we get in return.
Why would we make you a script to benifit your game to some extent and therefore potentially getting it plays and you tix.
Gimme' yo money punk |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 09 Sep 2014 09:50 PM |
... This forum is for scripters to help people and other scripters. I'm new to scripting and I am still trying to figure out how a script like this would work. I have so far scripted a working timed gate and a random map loader, but this team changing script is stumping me. Any suggestions? |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2014 09:52 PM |
| If you're new, then why does your name have 'dev' in it? |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 09 Sep 2014 09:55 PM |
@fruit I'm a high-detailed builder and I can make some amazing things, but I am just beginning to learn scripting. I moved to this account as my sALT so I could learn scripting without anyone bothering me on my main.
If you don't want to type the entire script, could someone post how I could accomplish this? I'm trying to learn and I'm making a game with my friend, so I hope you guys can help me. Thanks.
|Seems legit | devTools| |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 09 Sep 2014 10:00 PM |
Can someone give me legitimate help please? Thanks.
|Seems legit | devTools| |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
| |
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
| |
|
|
| 09 Sep 2014 10:50 PM |
function split(min,max,num,...) local tab = {...} local ntab = {}
if #tab == 1 and pcall(function() print(tab[i][1]) end) then old = tab[1] tab = {unpack(old)} end
for i = 1,num do ntab[i] = {} end
local current = ntab[1] local latest = 1
for i = 1,#tab do if not #current == max then table.insert(tab[i], current) end if current == last then current = ntab[1] else current = ntab[latest+1] latest = latest+1 end end
return unpack(ntab) end
team1,team2 = split(1,4,2,game.Players:GetChildren())
--this might not work..
You can do the rest I guess so you will still be learning |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 09 Sep 2014 10:54 PM |
| Wow. I don't understand 90% of that...lol... |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 09 Sep 2014 10:57 PM |
Thank you jade. I'll try it but I might not be able to edit it well without knowing how it works but whatever, I'll try. Thanks! |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2014 10:59 PM |
this is one I had help with a while back. it's way more easy to understand, and works flawlessly
function Assign() local half = math.floor(Game.Players.NumPlayers/2) local Plyrs = Game.Players:GetPlayers() for i = 1, #Plyrs do local rndom = table.remove(Plyrs, math.random(#Plyrs)) if i <= half then rndom.TeamColor = BrickColor.new("Bright green") else rndom.TeamColor = BrickColor.new("Bright blue") end end end |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 09 Sep 2014 11:01 PM |
| Thank! But what if i wanted a maximum of four on one team and both teams must have at least 1 (at least 2 people in the game)? |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
| |
|
|
| 09 Sep 2014 11:06 PM |
lol dude I can't just automatically make the script adorn to your game's given functions
I'm giving you a team assign script that's easy to understand.
if you wanna assign more people to one team, divide the half by 4. NumPlayers/4 = 20 , 5 people on each team
here's what you would use for 4 teams:
function Assign() local half = math.floor(Game.Players.NumPlayers/4) local Plyrs = Game.Players:GetPlayers() for i = 1, #Plyrs do local rndom = table.remove(Plyrs, math.random(#Plyrs)) if i <= half then rndom.TeamColor = BrickColor.new("Bright green") elseif i <= half * 2 then rndom.TeamColor = BrickColor.new("Bright Orange") elseif i <= half * 3 then rndom.TeamColor = BrickColor.new("Teal") else else rndom.TeamColor = BrickColor.new("Bright blue") end end end
|
|
|
| Report Abuse |
|
|
|
| 09 Sep 2014 11:08 PM |
| oh and btw this doesn't mess up if the half variable isn't even, which is why I said it was a really good function |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2014 11:09 PM |
| Acom that is too inefficient imo, mine isnt the most efficient, but it supports more than just 2 teams if needed, has minimum and maximum(i have to add minimum part later, and supports inserting of tables and objects. |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2014 11:24 PM |
| btw mine wont work, ill have to fix it |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2014 12:59 AM |
You're saying mines is inefficient when yours doesn't even work.
Mines hasn't ever broken not once. |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2014 04:51 PM |
| ITss a free model that you editted ggnore |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2014 07:04 PM |
Mines isn't a free model. Back in june, I had help from cntkillme when I was was making my game.
"ITss a free model that you editted ggnore"
That already says you know you're wrong, and you don't wanna face it WHEN you come back to this forum and see this. Good day |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 10 Sep 2014 08:55 PM |
...guys... dont argue on a forum post about whether its a free model or not lol... I was just looking for something that WORKED, not whether it was available to other players or not because I am editing the script for a new purpose.
|Seems legit | devTools |
|
|
| Report Abuse |
|
|
|
| 10 Sep 2014 09:06 PM |
I would suggest looping through each Player in the "Players" table. and then changing comparing their TeamColor against the Team's TeamColor.
Here's a few links you may benefit from.
http://wiki.roblox.com/index.php?title=TeamColor_%28Property%29 http://wiki.roblox.com/index.php?title=Generic_for Also, remember that ":GetChildren()" returns a read-only table.
And as an example,
for i,v in pairs(game.Players:GetPlayers()) do --Searches through the Player's table specifically for each Player Object. if v.TeamColor ~= TeamName.TeamColor then --Performs a check to compare the Color's of both the Player and the Team's TeamColor. v.TeamColor = NextTeam.TeamColor --Sets the Player's TeamColor to the next team's TeamColor. end end
This is just an example to help you, my apologies if I didn't explain well enough.
|
|
|
| Report Abuse |
|
|
|
| 10 Sep 2014 09:26 PM |
didn't test this yet, but much easier to understand kkbro
local getOnTeam(color) local toreturn = {}; for _,i in ipairs(game.Players:GetChildren()) do if(i.TeamColor == color) then rawset(toreturn, #toreturn+1, plr); end end return toreturn; end
local assign = function(min, max, path) local plrs = game.Players:GetPlayers(); for _,i in ipairs(plrs) do if(#getOnTeam(game.Teams[path]) < max and #getOnTeam(game.Teams["Guests"]) >= min) then i.TeamColor = game.Teams[path].TeamColor; elseif(#getOnTeam(game.Teams["Guests"]) < min or game.Teams[path]) >= max) then i.TeamColor = game.Teams["Guests"]; end end end
assign(1, 4, "Noobs"); |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 10 Sep 2014 09:28 PM |
| Thanks guys, it's working now :) |
|
|
| Report Abuse |
|
|