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

Why does my script stop at 'if' and don't continue?

Asked by 9 years ago

This is basically what constitutes f. :

for k, f in pairs(Game.Players:GetPlayers()) do coroutine.wrap(function() 

Now this is the PORTION where the trouble begins and where the script doesn't move on:

GameState = Instance.new("IntValue")
GameState.Parent = f.Backpack
GameState.Name = "GameState"
f.Backpack.GameState.Value = 1

if f.Backpack.GameState.Value == 1 then <----Line 108: It does a check, but if I do not have IntValue GameState in my backpack, the script does not continue.
Game.Lighting.BeginnerSword:Clone().Parent = f.Backpack wait(0.1)
f.Backpack.GameState:Destroy()
end
H = Instance.new("Hint")
H.Parent = game.Workspace
time = 122
Game_Launch_Part_Three()
end)()
t = t + 1 if t > #spawns then t = 1 
end
end
wait(.1)
end

This is basically what happens in a nutshell: To test this script, I go in-game and then I wait a bit for the script to place GameState in my backpack(and it does all of that fine) then I reset to test if the script keeps moving even if the player(s) do not have GameState in their backpack but it doesn't and it stops and gives these errors:

19:36:14.440 - GameState is not a valid member of Backpack
19:36:14.441 - Script 'Workspace.OvEngine(Game Script)', Line 108
19:36:14.442 - Stack End

I want it to continue even if I reset and do not have GameState in my backpack. It does not do that, it stops at 'if' and returns the following error. You do not need the whole script, I checked the whole script and it is working fine up to the 'if' part. That portion is the only portion that needs fixing. Question is why and how can I fix it?

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

Change line 6 to:

if (f.Backpack.GameState.Value == 1) then

If you don't have parenthesis, Lua reads it as a bool value.

0
Would that make a difference and would my script work after that? Overpride 0 — 9y
0
Yes. Shawnyg 4330 — 9y
Ad

Answer this question