Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this work in one place but not another?

This script is what makes my terminal run, I made it for one place and it works fine, but then I put it in another game of mine and it gets to the while wait(1) but it never goes into the for loop. I added some prints to see where it'd stop and it never gets to for i,v in pairs...

TimeLeft = script.Parent.TimeLeft
Owner = script.Parent.Owner
Cap = script.Parent.CapAmount
term = script.Parent.CaptureThing
while wait(1) do
	parttwo = term.B.Position
	partone = term.A.Position
	Region = Region3.new(partone,parttwo)
	r = 0
	b = 0
	for i,v in pairs(workspace:FindPartsInRegion3(Region,nil,100)) do
		if v.Parent:findFirstChild("Humanoid") then
			p = game.Players:GetPlayerFromCharacter(v.Parent)
			if p.TeamColor == BrickColor.new("Bright red") then r = r + 1
			elseif p.TeamColor == BrickColor.new("Bright blue") then
				b = b + 1
			end
			print(b)
			print(r)
			if b > r then
				if Cap.Value < 10 then
					Cap.Value = Cap.Value + 1
				end
				if Cap.Value == 10 then
					Owner.Value = "SST"
				end
			elseif r > b then
				if Cap.Value > 0 then
					Cap.Value = Cap.Value - 1
				end
				if Cap.Value == 0 then
					Owner.Value = "Raiders"
				end
			end
		end
	end
end

1 comment

0

Are you getting any Output at all? I can't see why this wouldn't work, unless you misnamed some Values.

1 answer

Only output I get is the prints when I put them in, I put a print before the for loop, and one right at the start of the for loop, the one before prints, the one inside does not. Like I said this works in my other place, but not my second one.

4 comments

0

Please don't make an answer to address my comment, edit your original post instead. I still don't see why this isn't working, though... Try adding this line: print(workspace:FindPartsInRegion3(Region,nil,100)) right before line 11, and tell me what that prints.

0

Prints table: 0F1840E8, table: 07C31570, etc... just abunch of different tables

0

Okay, that's good. Add a '#' symbol before 'workspace' in that print statement and tell me what it says then.

0

Alright, got it. For whatever reason, if I rotate the terminal, (Including the parts I use for region) it doesnt work anymore. So I just moved the parts without rotating terminal and it works. Ty for the help!

This discussion is preserved as it was. New answers, comments, and votes are closed.