IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 21 Feb 2013 10:26 AM |
I just want this script to simply randomise the players from the team neutral, putting them in the Red and Blue teams, then killing them, once I say !gamestart ...
This is what is displayed in the roblox error monitoring
Workspace.Script2:11: attempt to call global 'randomizetable' (a nil value)
print("gamestart running") ---------------------- local admins = {"iceorb"}
function onChatted(msg, speaker) if msg == "!gamestart" then _G.Teams = {} _G.Teams["Red"] = {} _G.Teams["Blue"] = {} local plrs=randomizetable(game.Players:GetChildren()) --<<< WHERE IS THIS FUNCTION? for i,v in ipairs(plrs) do if v~=nil and v.Parent~=nil then local teams = game.Teams:GetChildren() local t = (i%(#teams))+1 v.TeamColor=teams[t].color _G.Teams[teams[t].name][v.Name] = v end end end end
function onPlayerEntered(newPlayer) repeat wait() until newPlayer newPlayer.Chatted:connect(function(msg) for _,v in pairs(admins) do if newPlayer.Name:lower() == v:lower() then onChatted(msg,newPlayer) end end end) end
game.Players.PlayerAdded:connect(onPlayerEntered) |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 21 Feb 2013 10:33 AM |
| The thought of the basic function of the script sounds so simple ''Chat command for admins, say !gamestart and it rebalances teams to Red and Blue, and kills everyone'' I don't get why it no work qq |
|
|
| Report Abuse |
|
|
koen500
|
  |
| Joined: 23 Feb 2011 |
| Total Posts: 2277 |
|
|
| 21 Feb 2013 10:34 AM |
| randomizetable(game.Players:GetChildren()) |
|
|
| Report Abuse |
|
|
koen500
|
  |
| Joined: 23 Feb 2011 |
| Total Posts: 2277 |
|
|
| 21 Feb 2013 10:35 AM |
| That is your function which doesn't exist. |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 21 Feb 2013 10:37 AM |
| Alright, but once I delete that function, it still doesn't seem to work? |
|
|
| Report Abuse |
|
|
koen500
|
  |
| Joined: 23 Feb 2011 |
| Total Posts: 2277 |
|
|
| 21 Feb 2013 10:38 AM |
The function is not created in that script. Create it. |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
| |
|
koen500
|
  |
| Joined: 23 Feb 2011 |
| Total Posts: 2277 |
|
|
| 21 Feb 2013 10:47 AM |
You need to create function randomisetable()
|
|
|
| Report Abuse |
|
|
koen500
|
  |
| Joined: 23 Feb 2011 |
| Total Posts: 2277 |
|
| |
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 21 Feb 2013 10:51 AM |
| Then I would need to add another end to close it or? |
|
|
| Report Abuse |
|
|
koen500
|
  |
| Joined: 23 Feb 2011 |
| Total Posts: 2277 |
|
|
| 21 Feb 2013 10:52 AM |
Of course.
Every function needs to close. |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 21 Feb 2013 10:54 AM |
Alright, added function randomizetable() underneath the onChatted function, then added another end.
Gonna test now. |
|
|
| Report Abuse |
|
|
koen500
|
  |
| Joined: 23 Feb 2011 |
| Total Posts: 2277 |
|
| |
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 21 Feb 2013 10:56 AM |
Alright, NO errors was displayed but, the script doesn't seem to perform it's function at all?
Doesn't put me in a team when I say !gamestart |
|
|
| Report Abuse |
|
|
koen500
|
  |
| Joined: 23 Feb 2011 |
| Total Posts: 2277 |
|
|
| 21 Feb 2013 11:02 AM |
I think you didn't describ what the function does...
Wat did you put inside the function? |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
| |
|
|
| 21 Feb 2013 11:19 AM |
You need to make the function actually do something.. You can't just do:
function randomizetable()
end
and expect it work. |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 21 Feb 2013 11:21 AM |
| The function I want it to do is to randomise the teams then kill the players? |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 21 Feb 2013 11:23 AM |
| Sorry, a friend of mine created the script for me, I was just struggling to fix it :( |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2013 11:26 AM |
function randomizetable(tab) local newTab = {} for i, v in pairs(tab) do repeat local n = math.random(#tab) until newTab[n] ~= nil newTab[n] = v; end return newTab; end
There's the function you're looking for. However, it will probably freeze the game if there are less than 2 players there when the function fires. |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 21 Feb 2013 11:27 AM |
| Right so where would this function be placed? |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 21 Feb 2013 11:39 AM |
| Alright I'll test this now |
|
|
| Report Abuse |
|
|