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

Part does nothing when clicked on to activate the camera manipulation, how do I fix it?

Hello, What I'm trying to create is when a player clicks on a part, which would activate the MouseClick event on the ClickDetector, and when clicked, it changes the camera position to the part, and rotates around it, for some reason when I tried it out, nothing happens... Here is the script that I was talking about...

Note: The Child inside the Part is the Local Script and the ClickDetector.

local target = script.Parent
local camera = game.Workspace.CurrentCamera

local angle = 0
local isPlaying = false

script.Parent.ClickDetector.MouseClick:connect(function()	
	
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CameraSubject = target
	
	isPlaying = true	
	
end)

while isPlaying do
	camera.CFrame = CFrame.new(target.Position)
					* CFrame.Angles(0, angle, 0)
					* CFrame.new(0, 3, 5)
					
	angle = angle + math.rad(1)
	
	wait()	
	
end

Thank you!

~NanotechSci

1 answer

Hi Nano! Your issue here is that the while loop checks for variable "isPlaying" once, and since isPlaying returns false, the loop will end and will not be repeated. Without going into the heavier stuff, I'd recommend you place your while loop inside of your ClickDetector event!

Nice work!

1 comment

0

Hello! I have tried putting the while loop inside the event, but nothing happens :(

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