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 » Scripting Helpers
Home Search
 

Re: Script Help ... yet again lol

Previous Thread :: Next Thread 
IceOrb is not online. 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 is not online. 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 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
21 Feb 2013 10:34 AM
randomizetable(game.Players:GetChildren())
Report Abuse
koen500 is not online. 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 is not online. 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 is not online. 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 is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
21 Feb 2013 10:44 AM
function scrambleteams()

Report Abuse
koen500 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
21 Feb 2013 10:47 AM
You need to create function randomisetable()
Report Abuse
koen500 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
21 Feb 2013 10:48 AM
randomizetable*
Report Abuse
IceOrb is not online. 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 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
21 Feb 2013 10:52 AM
Of course.

Every function needs to close.
Report Abuse
IceOrb is not online. 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 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
21 Feb 2013 10:55 AM
I'm done here.
Report Abuse
IceOrb is not online. 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 is not online. 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 is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
21 Feb 2013 11:16 AM
What do you mean?
Report Abuse
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
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 is not online. 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 is not online. 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
SamuelKingx is not online. SamuelKingx
Joined: 27 Jan 2012
Total Posts: 3472
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 is not online. 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 is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
21 Feb 2013 11:39 AM
Alright I'll test this now
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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