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: How Would i get the characters?

Previous Thread :: Next Thread 
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
15 Jul 2015 08:19 AM
so i want to get all players characters, but when i try to name a variable players with the value being game.Players:GetPlayers() instead of some for loops it tells me that Character is a nil value

local players = game.Players:GetPlayers()
local run = true
local Message = workspace.LobbyMessage
local RoundEnd = true

function blah()

end

while wait() do
local AlivePlayers = 0
wait(5)
if run then
run = false
Message.Text = "Preparing..." -- we'll get fancy with GUIs later
local maps = game.ReplicatedStorage.Maps:GetChildren()
Map = maps[math.random(1,#maps)]
local NewMap = Map:Clone()
NewMap.Parent = workspace
wait(1)
Message.Text = ""
while true do
for i, players in pairs(game.Players:GetPlayers()) do
AlivePlayers = game.Players.NumPlayers
players.Character.Humanoid.Died:connect(function()
AlivePlayers = AlivePlayers - 1
end)
end
for i, players in pairs(game.Players:GetPlayers()) do
players.Character.Torso.CFrame = CFrame.new(NewMap.Start.Position.X,NewMap.Start.Position.Y+12,NewMap.Start.Position.Z)
end
players.Character.Humanoid.WalkSpeed = 0
wait(2)
Message.Text = "GO"
players.Character.Humanoid.WalkSpeed = 50
wait(.3)
Message.Text = ""
end
if RoundEnd == true then
NewMap.End.Touched:connect(function(It)
run = true
local spawn = workspace.SpawnLocation
local player = game.Players:GetPlayerFromCharacter(It.Parent)
print("waiting")
for i,players in pairs(game.Players:GetPlayers()) do
players.Character.Torso.CFrame = CFrame.new(spawn.Position.X+i,spawn.Position.Y+12,spawn.Position.Z+i)
Message.Text = (player.Name.." Has won")
players.Character.Humanoid.WalkSpeed = 16
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value+50
NewMap:Destroy()
wait(3)
Message.Text = ("")
wait(5)
end
end)
spawn(function()
repeat wait() until AlivePlayers <= 0
run = false
Message.Text = "Everyone died... gg"
wait(3)
Message.Text = ""
NewMap:Destroy()
run = true
end)
end
end
end




<3 cats <3
Report Abuse
BigThunderBoy is not online. BigThunderBoy
Joined: 23 Jun 2012
Total Posts: 125
15 Jul 2015 08:21 AM
Okay, you should do this

local players = game.Players:GetChildren()

for _, player in pairs(players) do
local char = player.Character
if char then


end
end
Report Abuse
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
15 Jul 2015 08:24 AM
it errors right here and if i do it for each player then the message happens for each player

players.Character.Humanoid.WalkSpeed = 0
wait(2)
Message.Text = "GO"
players.Character.Humanoid.WalkSpeed = 50
wait(.3)
Message.Text = ""


<3 cats <3
Report Abuse
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
15 Jul 2015 08:30 AM
so i CANT do a for loop there


<3 cats <3
Report Abuse
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
15 Jul 2015 09:17 AM
bump


<3 cats <3
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
15 Jul 2015 09:55 AM
I felt that I was obliged to offer my own solution.

local replicator = _G.Valkyrie:GenerateWrapper(true);
replicator.mt.__index = replicator(function(t,k)
if type(t) == 'table' then
local r = {};
for n,v in next,t do
r[n] = v[k];
end
return r;
end
return t[k];
end)
replicator.mt.__newindex = replicator(function(t,k,v)
if type(t) == 'table' then
for _,u in next,t do
u[k] = v;
end
return nil;
end
t[k] = v;
end)

Usage:
replicator(game.Players:GetChildren()).Character.Humanoid.WalkSpeed = 16;
Report Abuse
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
15 Jul 2015 07:04 PM
what does 'replicator' do exactly?


<3 cats <3
Report Abuse
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
15 Jul 2015 07:39 PM
bump


<3 cats <3
Report Abuse
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
15 Jul 2015 07:42 PM
well actually what does GenerateWrapper do?


<3 cats <3
Report Abuse
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
15 Jul 2015 09:38 PM
bump


<3 cats <3
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
15 Jul 2015 10:52 PM
http://www.roblox.com/PlayersDeadAliveScript-item?id=255028728


"Talk is cheap. Show me the code." - Linus Torvalds
Report Abuse
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
16 Jul 2015 12:16 AM
im not looking for if the players are alive


<3 cats <3
Report Abuse
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
16 Jul 2015 01:17 AM
so what does replicate do?


<3 cats <3
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
16 Jul 2015 01:59 AM
It's an object that makes it so that if you're too stupid to know how to engineer your for loops, it does it for you.
Report Abuse
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
16 Jul 2015 04:39 AM
so could you explain a little further how that was put together? like why is Valkyrie in there and what does _G do?


<3 cats <3
Report Abuse
bubbaman73 is not online. bubbaman73
Joined: 02 Feb 2013
Total Posts: 795
16 Jul 2015 05:50 AM
anyone?


<3 cats <3
Report Abuse
Jradi is online. Jradi
Joined: 15 Aug 2012
Total Posts: 10015
16 Jul 2015 07:25 AM
You can't get the characters of ALL players just because you set a variable of all the players (in a table).

for i,v in pairs(Players) do
-- insert what you want to do to EACH character
end


=[ Chairman of Arlite Core
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