KipykoJoin Date: 2014-06-01 Post Count: 249 |
Thing is When I run this function in my script no errors pop up. So I don't know whats wrong, But what this function is suppose to do is it checks the InGame Value of all players in the game every second and if the value = false then the count = count + 1 and if the value = to true then the count = count -1 and once the value of count = 0 the game timer = 0 so the game ends.
the problem with it though is its not changing the value of count (within the intValue NumEnd of workspace) so when this function does it's usual check every second at this area later on in the script, It sees the value is still at 0 so the game ends even though it shouldn't be ending. (Note: I think the problem is with the counting of the value of InGame but im not to sure what im doing wrong)
please help me if you can.
If you do not know what I'm saying Please DON'T reply to this thread.
---------------------------------------------------------------------------------
count = game.Workspace.NumEnd.Value
---------------------------------------------------------------------------------
while timer.Value > 0 do
timer.Value = timer.Value - 1
h.Text = "TimeLeft: " .. timer.Value
EndGame()
wait(1)
end
--------------------------------------------------------------------------------
function EndGame()
local count = 0
for i, v in pairs(game.Players:GetPlayers()) do
StillAlive = v:FindFirstChild("InGame")
if StillAlive then do
if StillAlive == false then
count = count + 1
else
if StillAlive == true then
count = count - 1
end
end
end
end
end
print("Counting")
if count <= 1 then
timer.Value = 0
elseif
count > 1 then
print("Testing")
end
end |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
. |
|
ReiyussJoin Date: 2009-09-27 Post Count: 3 |
O_O |
|
|
---------------------------------------------------------------------------------
count = game.Workspace.NumEnd.Value
---------------------------------------------------------------------------------
while timer.Value > 0 do
timer.Value = timer.Value - 1
h.Text = "TimeLeft: " .. timer.Value
EndGame()
wait(1)
end
--------------------------------------------------------------------------------
function EndGame()
local count = 0
for i, v in pairs(game.Players:GetPlayers()) do
StillAlive = v:FindFirstChild("InGame");Spawn(wait)
if StillAlive then do
if StillAlive == false then
count = count + 1
else
if StillAlive == true then
count = count - 1
end
end
end
end
end
print("Counting")
if count <= 1 then
timer.Value = 0
elseif
count > 1 then
print("Testing")
end
end |
|
KodranJoin Date: 2013-08-15 Post Count: 5330 |
I'm not 100% sure but you probably want to do v.Character:FindFirstChild("InGame") |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
Thank you for the help <3 both of you :3
sadly its still not working T_T
but thank you either way <3 |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
(>O_O)> |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
. |
|
KodranJoin Date: 2013-08-15 Post Count: 5330 |
So since count is staying at 0, that means StillAlive is neither true nor false leaving only 1 explanation; it is nil. What script are you creating StillAlive in? |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
game.Players.PlayerAdded:connect(function(player)
stats = Instance.new("IntValue", player)
stats.Name = "leaderstats"
points = Instance.new("IntValue", stats)
points.Name = "Points"
ingame = Instance.new("BoolValue", player)
ingame.Name = "InGame"
end)
just a simple leaderboard script InGame is = to StillAlive.
I know my InGame value is working if it wasnt some of my other scripts wouldn't be working I just dont know why it isn't counting there must be something wrong with my function that I cant see.
but thank you for trying to help me out though <3 |
|
KodranJoin Date: 2013-08-15 Post Count: 5330 |
Mind doing a print if StillAlive == nil? I love programming and I'm making an app but my artist's computer died so he can't do anything so I don't have any new art to add to the game, so I thought I'd come here and try to help some people out as best I could. |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
Oh that sounds really cool :3 I hope your game becomes a hit :D but im not sure what you mean by print StillAlive == Nil I'm sorta still a novice scripter even though some people think different with some of the codes I do XD. I mostly just been teaching myself :3.
I wish I had your scripting knowledge so I could also help people out but sadly its still in development XD :P. |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
ohhh stupid me now i know what you mean by print if stillalive == nil im very dumb at some moments XD |
|
KodranJoin Date: 2013-08-15 Post Count: 5330 |
It's great that you're learning programming and thanks :D
Sorry I was kind of vague I mean print something random like "hi" if StillAlive == nil so if it says hi in the output you know stillalive is nil. |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
I did a print and its not showing up a nil value within my output.
I'm even more confused on why it isn't working XD. |
|
KodranJoin Date: 2013-08-15 Post Count: 5330 |
It's 1 AM here but now you have my curiosity and I am determined to fix this problem for you lol.
is the timer going down? |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
now I'm even more sure its something to do with this part of my script
but I'm not so sure what I did wrong hmmmmm.
-----------------------------------------------------------------------
function EndGame()
local count = 0
for i, v in pairs(game.Players:GetPlayers()) do
StillAlive = v:FindFirstChild("InGame")
if StillAlive then do
if StillAlive == false then
count = count + 1
else
if StillAlive == true then
count = count - 1
----------------------------------------------------------------------- |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
lol your 3 hours in the future for me :O anyways
yeah I did a test with the script for the
print("Counting")
if count > 1 then
timer.Value = 0
elseif
count <= 1 then
print("Testing")
i just switched the values on it to see if the Print would help me out more and it did so I see the words counting and testing every second for 60 seconds in my output :3
|
|
KodranJoin Date: 2013-08-15 Post Count: 5330 |
Honestly the only thing I can think of is a silly mistake such as setting the timer value to 0 by default or something. |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
oh no worries i made quadruple sure that it wasn't set at 0 i got worried sometimes that it was the source but sadly it wasn't XD.
|
|
KodranJoin Date: 2013-08-15 Post Count: 5330 |
OHH! okay, you set count to 0 then you add 1 because stillalive is false(cause it is by default) and then it's equal to less than or equal to 1(cause it is 1) then, it sets timer to 0 and never checks again.
I'm going to bed I hope that was right! |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
yeah thats correct :3 |
|
ReiyussJoin Date: 2009-09-27 Post Count: 3 |
O_O |
|
KipykoJoin Date: 2014-06-01 Post Count: 249 |
? |
|