Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I'm confused, why doesn't this work properly?

Asked by 9 years ago

Why does the second "if" play if the Finished.Value is already true?

while true do wait()

if script.Parent.Finished.Value == true and script.Finished.Value == false and game.Workspace.Finished.First.Took.Value == false then
script.Parent.Results.Visible = true
script.Finished.Value = true
game.Workspace.Finished.First.Took.Value = true
game.Workspace.Finished.First.Value = "1 - "..game.Players.LocalPlayer.Name

wait(1)
if script.Parent.Finished.Value == true and script.Finished.Value == false and game.Workspace.Finished.Second.Took.Value == false then
script.Parent.Results.Visible = true
script.Finished.Value = true
game.Workspace.Finished.Second.Took.Value = true
game.Workspace.Finished.Second.Value = "2 - "..game.Players.LocalPlayer.Name
end

end end

3 answers

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Could you explain what you're trying to do here? I'm confused.

You have the second if statement nested within the first, and I can't see why.

By the way, ValueObjects have a Changed event that only fires when the Value changes, so you don't have to put this code in an infinite loop.

0
I'm trying to keep that 2nd statement from running if script.Finished.Value == true sergantbloxxer 5 — 9y
Ad
Log in to vote
-1
Answered by
iFlusters 355 Moderation Voter
9 years ago

Try putting:

elseif script.Parent.Finished.Value == true and script.Finished.Value == false and game.Workspace.Finished.Second.Took.Value == false then

for the start if the second 'if', so just change 'if' to 'elseif'

0
Nope, won't work. sergantbloxxer 5 — 9y
Log in to vote
-1
Answered by 9 years ago

You need to be constantly checking for the value, so I recommend doing something like this:

repeat wait() until script.Parent.Finished.Value == true and script.Finished.Value == false

So basically, make it wait for that value to change in order to run the code below. Did this help?

0
Is it supposed to be the first line? It won't work for me that way. sergantbloxxer 5 — 9y

Answer this question