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

i have a problem i am trying to make a path detect a variable can someone help me?

local Part = game.Workspace.Next ColorParentStart = 0 Next = tostring(ColorParentStart + 1)

Part.BrickColor = BrickColor.new("Really red")

I am trying to make a tower of parts turn red one by one (i will use the wait func later)

but I get an error: Next is not a valid member of Workspace I want to use the var Next as a name for the target

can someone help me?

sincerely Krijn

1 answer

✓ Accepted answer

Hello there! There are some definite logic issues with your script, but that is why you are here. I hope to help you with my answer. The first issue is that you are using the variable Next when it is not defined in the script. Now I know you have:

local Part = game.Workspace.Next

but that is naming the variable Part, not Next. The next issue is that your code will execute once which means that only one brick would turn red if your script worked correctly. The way to fix this problem is a loop. There is one issue I have with the approach you are using. How will the script know when to stop? One simple fix I can think of would be to have a model in workspace with all the parts you want changed in it(I will name it tower). Here is an example of what you can do:

local tower = game.Workspace.Tower -- this would have the parts in it
local amountOfParts = #tower:GetChildren() -- this is to get the amount of parts in the tower model so it would be advised not to put anything else in it
for i = 1, amountOfParts do -- we are looping now this will execute for every object in the tower model
	local part = tower:FindFirstChild(tostring(i)) -- i is the number we are at in the counter
	if part and part:IsA("BasePart") then -- making sure the child is a part and exists
		part.BrickColor = BrickColor.new("Really red")
	end
end

I hope this helps and makes sense. Have a great day scripting! Note: If you have any comments or questions feel free to post them below.

2 comments

0

sorry i guess i copied my script incorectly i did have the Next variable

0

thanks for helping me!! i apreciate it

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