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: Just prints nil?

Previous Thread :: Next Thread 
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 12:53 PM
Help?

h = game.Lighting.msg
minigames = game.ServerStorage.Minigames:GetChildren()
playerAlive = nil

game.Players.PlayerAdded:connect(function(player)
stats = Instance.new("IntValue", player)
stats.Name = "leaderstats"

units = Instance.new("IntValue", stats)
units.Name = "Units"

wins = Instance.new("IntValue", stats)
wins.Name = "Wins"

Ingame = Instance.new("BoolValue", player)
Ingame.Name = "InGame"
end)

while true do
if game.Players.NumPlayers > 1 then
h.Value = "Minigame is currently being chosen; please wait."
wait(3)
ranGame = math.random(1, #minigames)
gameChosen = minigames[ranGame]
h.Value = "Minigame Chosen: " .. gameChosen.Name
wait(3)
gameChosenClone = gameChosen:Clone()
gameChosenClone.Parent = game.Workspace
wait(3)
spawns = gameChosenClone.spawns:GetChildren()
for i,v in pairs(game.Players:GetPlayers()) do
name = v.Name
check = game.Workspace:FindFirstChild(name)
if check then
checkHumanoid = check:FindFirstChild("Humanoid")
if checkHumanoid then
v.Character:MoveTo(spawns[i].Position)
v.InGame.Value = true
end
end
end
for i, v in pairs(game.Players:GetChildren()) do -- count alive player
alive = v:FindFirstChild("InGame")
if alive then
if alive == true then
playerAlive = playerAlive + 1
end
end
end
for i = 3, 1, -1 do
h.Value = "Game starts in: " .. i
wait(1)
end
if gameChosenClone.Name == "Dissapearing Plates - Made by Gladii" then
timeTillGameEnds = 45
for i = timeTillGameEnds, 1, -1 do
h.Value = "Time left: " .. i
print(playerAlive) --print alive player
wait(1)
end
end
if gameChosenClone.Name == "Spleef - Made by Gladii" then
timeTillGameEnds = 60
for i = timeTillGameEnds, 1, -1 do
h.Value = "Time left: " .. i
print(playerAlive) -- pritn alive player
wait(1)
end
end
h.Value = "Round has ended!"
wait(3)
h.Value = "Giving Units to players who won..."
for i,v in pairs(game.Players:GetPlayers()) do
ingame = v:FindFirstChild("InGame")
if ingame then
if ingame.Value == true then
v.leaderstats.Units.Value = v.leaderstats.Units.Value +10
v.leaderstats.Wins.Value = v.leaderstats.Wins.Value +1
end
end
end
wait(3)
gameChosenClone:Destroy()
else
h.Value = "Waiting for 1 more player..."
end
wait(1)
end
while true do
wait()
for i,v in pairs(game.Players:GetChildren()) do
ingame = v:FindFirstChild("InGame")
if v.Character.Humanoid.Health == 0 then
if ingame then
ingame.Value = false
end
end
end
end
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 01:13 PM
s
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
14 Sep 2014 01:19 PM
first or second print?
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 01:22 PM
Where it says
print(alivePlayer)
???
In that case,
both prints.
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
14 Sep 2014 01:23 PM
playerAlive = nil
change to
playerAlive = 0
Should work
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 01:25 PM
Now it just prints 0.

Must be something with
for i, v in pairs(game.Players:GetChildren()) do -- count alive player
alive = v:FindFirstChild("InGame")
if alive then
if alive == true then
playerAlive = playerAlive + 1
end
end
end
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
14 Sep 2014 01:28 PM
InGame a boolvalue?
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 01:30 PM
Yes.
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
14 Sep 2014 01:42 PM
if alive.Value try that
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
14 Sep 2014 01:43 PM
if alive.Value == true then
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 01:44 PM
Workspace.Main Script:47: attempt to perform arithmetic on global 'playerAlive' (a nil value)
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 01:47 PM
line 47 is playerAlive = playerAlive + 1
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 01:48 PM
Oh I fixed it. forsome reason PlayerAlive turned itself to nil..
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
14 Sep 2014 01:49 PM
Did you edit the script because if line 47 is playerAlive = playerAlive + 1 the script you posted line 47 is a end lol um did you revert "playerAlive " back to nil or is it still 0?
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 01:49 PM
Well, now it dosn't change, When a player gets taken out of the game it still says 2.
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
14 Sep 2014 01:49 PM
oh Lua does that sometimes lol so did it work?
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
14 Sep 2014 01:50 PM
Where do you - it? see your thing only adds
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
14 Sep 2014 01:51 PM
I mean + lol my bad
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 01:52 PM
Well its a while true do loop.
I can simply take a player out of the game by killing him.
So 1 player is left. It's still printing 2.
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
14 Sep 2014 01:52 PM
No scratch that ugh need to wake up more lol
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
14 Sep 2014 01:56 PM
just add this at the end


playerAlive = playerAlive - 1

right under ingame.Value = false

See While True do you only have

playerAlive = playerAlive + 1

nothing minuses it so the number should never go down
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 01:57 PM
That while true do down there dosn't work. Not sure why I added it. But I have a fix And I can do your idea.
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 01:58 PM
The problem is its a localscript inside the players backpack.

Here is the script.
plr = script.Parent.Parent
repeat wait() until plr.Character.Humanoid.Health == 0
Value = plr:FindFirstChild("InGame")
Value.Value = false
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
14 Sep 2014 02:04 PM
Oh wow I did not notice that weird loop yeah get ride of that extra while true do :X
Any ways just adding what I put should work in theory that or make a another script and make that the remove players from InGame script and it should all work
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
14 Sep 2014 02:06 PM
I've added
while true do
wait()
for i,v in pairs(game.Players:GetChildren()) do
repeat wait() until v.Character.Humanoid.Health == 0
playerAlive = playerAlive - 1
Value = v:FindFirstChild("InGame")
Value.Value = false
end
end
Hasn't seemd to work.
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