This is a much, much simplified version of a script I'm working on. But the logic still applies. Why won't the while loop execute? The function prints "1", but the while loop never starts.
function FigureChanged(object)
index = nil
if object.Name == "Player1" then
index = 1
end
print(index)
end
workspace.ChildAdded:Connect(FigureChanged)
while index == 1 and wait(.1) do
print"here"
end

2 comments
This works, thank you very much! I do wonder why the original code didn't work though.
No problem, glad I could help.