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: Main Game Script Help

Previous Thread :: Next Thread 
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
03 Jun 2014 04:59 PM
Error is on line 18





function killall()
for i,v in pairs (game.Workspace:GetChildren()) do
if v.Humanoid ~= nil then
v.Humanoid.Health = 0
player = game.Players:GetPlayerFromCharacter(v)
player.TeamColor = BrickColor.new("Really black")
end
end
end

function choose()
p = game.Players:GetChildren()
for i,v in pairs (game.Players:GetChildren()) do
if v.ClassName =="Player" then
v.TeamColor = BrickColor.new("Lime green")
end
chosen = math.random(1,#p)
chosen.TeamColor = BrickColor.new("Really red")
end
end

function teleport()
for i,c in pairs (game.Workspace:GetChildren()) do
if c.ClassName == "Model" and c.Humanoid ~= nil then
c.Torso.CFrame = game.Workspace.Teleport.CFrame * CFrame.new(5,1,5)
end
end
end


local allPlayersDead = false
local bossDead = false

function check()

end
for i, collect in pairs (game.Players:GetChildren())do
if collect.ClassName == "Player" then
if collect.TeamColor == "Lime green" or collect.TeamColor == "Really red" then
print("Running")
else
m = Instance.new("Hint")
m.Parent = game.Workspace
m.Text = 'Round Over'
end
end
end


while wait(30) do
choose()
teleport()
check()
wait(10)
killall()
end
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
03 Jun 2014 05:00 PM
I showed where the error is.





function killall()
for i,v in pairs (game.Workspace:GetChildren()) do
if v.Humanoid ~= nil then
v.Humanoid.Health = 0
player = game.Players:GetPlayerFromCharacter(v)
player.TeamColor = BrickColor.new("Really black")
end
end
end

function choose()
p = game.Players:GetChildren()
for i,v in pairs (game.Players:GetChildren()) do
if v.ClassName =="Player" then
v.TeamColor = BrickColor.new("Lime green")
end
chosen = math.random(1,#p)
chosen.TeamColor = BrickColor.new("Really red") ---Attempt to call a numbervalue?
end
end

function teleport()
for i,c in pairs (game.Workspace:GetChildren()) do
if c.ClassName == "Model" and c.Humanoid ~= nil then
c.Torso.CFrame = game.Workspace.Teleport.CFrame * CFrame.new(5,1,5)
end
end
end


local allPlayersDead = false
local bossDead = false

function check()

end
for i, collect in pairs (game.Players:GetChildren())do
if collect.ClassName == "Player" then
if collect.TeamColor == "Lime green" or collect.TeamColor == "Really red" then
print("Running")
else
m = Instance.new("Hint")
m.Parent = game.Workspace
m.Text = 'Round Over'
end
end
end


while wait(30) do
choose()
teleport()
check()
wait(10)
killall()
end
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
03 Jun 2014 05:14 PM
Bump :/
Report Abuse
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
03 Jun 2014 05:17 PM
p = game.Players:GetChildren()
for i,v in pairs (game.Players:GetChildren()) do
if v.ClassName =="Player" then
v.TeamColor = BrickColor.new("Lime green")
end
chosen = math.random(1,#p) -- Chosen is a number...
chosen.TeamColor = BrickColor.new("Really red") ---Attempt to call a numbervalue?

To fix, replace the defining 'chosen' line with this:

chosen = p[math.random(1, #p)]
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
03 Jun 2014 05:21 PM
Thx but now there is an error on line 3


function killall()
for i,v in pairs (game.Workspace:GetChildren()) do
if v.Humanoid ~= nil then -- humanoid isn't a valid child of terrain :/
v.Humanoid.Health = 0
player = game.Players:GetPlayerFromCharacter(v)
player.TeamColor = BrickColor.new("Really black")
end
end
end
Report Abuse
DigitalVeer is not online. DigitalVeer
Joined: 23 Jun 2009
Total Posts: 4182
03 Jun 2014 05:22 PM
Hey!
Nice attempt!
Just some small tips!

In your killall function, it's a lot more effecient to loop through players!

function killall()
for i,v in pairs (game.Players:GetPlayers()) do
if v.Character:FindFirstChild("Humanoid") then
v.Character.Humanoid.Health = 0
v.TeamColor = BrickColor.new("Really black")
end
end
end


Along same thing here:

function teleport()
for i,c in pairs (game.Players:GetPlayers()) do
if c.Character:FindFirstChild("Torso") then
c.Character.Torso.CFrame = game.Workspace.Teleport.CFrame * CFrame.new(5,1,5)
end
end
end



Now to fix the choose function
The reason it's erroring is because you're trying to set the Color of a random number e.o

This should fix it

function choose()
p = game.Players:GetPlayers()
for i,v in pairs(p) do
v.TeamColor = BrickColor.new("Lime green")
end
rand = math.random(1,#p)
randplr = game.Players[rand]
randplr.TeamColor = BrickColor.new("Really red")
end


This part here is confusing me:
function check()

end

An empty function?

And also:

Change this

for i, collect in pairs (game.Players:GetChildren())do
if collect.ClassName == "Player" then
if collect.TeamColor == "Lime green" or collect.TeamColor == "Really red" then


To

for i, collect in pairs(game.Players:GetPlayers()) do
if collect.TeamColor == BrickColor.new("Lime green") or collect.TeamColor == BrickColor.new("Really red") then
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
03 Jun 2014 05:28 PM
Thx Bro!
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