My script for changing camera position when entering a room isnt working

hey my script for changing camera position when entering a room isnt working, can someone help me, what I wanted was to make something like how in pokemon brick bronze, the camera, indoors was locked at a certain angle and moved only on the x axis when a player moved. I want to make it so while inside of a region, it will occur like this, but elsewhere not.

your else statement is outside the scope of your if statement

thx but it still doesnt work after I fixed that for some reason

in your else statement, the = has to be ==
i dont exactly know why, nor do i care.
its just how scripting is.

edit: nvm, thats for elseif statements
try putting the camera change on a different line idk

I tried that but it is still not working

Are you actually getting any prints?

@e71 no I am not getting any prints

That right there is some pretty valuable information.

Right under the line where you define the variable "parts" could you please write

print(#parts)

That’ll print the number of things in that table, the only place where found can possibly be set as true is inside a pairs() loop for parts. This means that it’ll only run for the number of things in the table. If it isn’t over 0 then found won’t ever have a chance of being set to true therefore making it impossible for the camera’s CFrame to ever be set.

Also you should work on how you program in Roblox. To make a start, instead of writing if Found == true, you can simply write if Found because that equates to if Found == true. Also I’ve heard that you shouldn’t use while wait() do loops because it’s slower than a regular while true do loop. Use while true do task.wait(). Along with mentioning that you should know that you should also use task.wait() instead of the old and deprecated wait().