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

Why wont this code work? It Should move the camera after a part is clicked.

script.Parent.MouseClick:Connect(function()
local Player = game.Players.LocalPlayer		 
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local Cameras = workspace:WaitForChild('Camera')
local CameraPart1 = Cameras:WaitForChild('CameraPart1')
local CameraPart2 = Cameras:WaitForChild('CameraPart2')

repeat wait()
	Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = CameraPart1.CFrame

for Num = 0,1,.01 do
	Camera.CFrame = CameraPart1.CFrame:lerp(CameraPart2.CFrame,Num)
	wait()
end

end)

I have this in a local script that is inside of a Clickdetector. When I click the button in the game it does not do anything or even output anything. This script should set up the camera and then move it where I want it. I am new to Roblox Lua and got this by watching a youtube video. I would appreciate some help.

1 answer

✓ Accepted answer

LocalScripts not parent to something connected to the player such as the playergui or their character won't run.

You'll need to parent this localscript a place like StarterPack for it to work.

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