-
What do you want to achieve? Hello, i have a proximity prompt on a helicopter where it would make your camera focus on the helicopter. (The helicopter is just a basic model)
-
What is the issue? The camera dosen’t follow the helicopter.
-
What solutions have you tried so far? I tried changing the camera subject and the cameratype but it dosen’t work (when i try manually it works, but not in the script).
a laggy solution is to lock your cam into a part then use CFrame.lookat() to look at the heli or u can use something like this
local lookVector = (partToLookAt.Position - camera.CFrame.Position).Unit camera.CFrame = CFrame.new(camera.CFrame.Position,camera.CFrame.Position + lookVector)
remember to set the cam to scriptable
Will i still be able to look around just like the default character if i do that?
umm no you cannot move your cam around while it’s focusing on the helicopter because the cam is locked to the heli
when you changed the camera subject, did you do it from a localscript? As you’re only able to control the camera from the client.
Yeah when i changed the camera subject i did it from a local script
Can you send pictures of the code and where the script is located?
Because as far as I know it should work if you successfully execute it from a local script
ok i think you are struggling too much here is the script, it works on my side, just put it under the proxypromt and it should work fine i assume
local ProximityPrompt = script.Parent
local LookAtPart = workspace.PartToLookAt
ProximityPrompt.Triggered:Connect(function()
local player = game.Players.LocalPlayer
local character = player.Character
if character then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
local playerRoot = humanoid.RootPart
if playerRoot then
local camera = game:GetService("Players").LocalPlayer.Camera
if camera then
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(playerRoot.Position, LookAtPart.Position)
local function onCharacterAdded(newCharacter)
local newHumanoid = newCharacter:FindFirstChildOfClass("Humanoid")
if newHumanoid then
humanoid = newHumanoid
playerRoot = newHumanoid.RootPart
end
end
character.ChildAdded:Connect(onCharacterAdded)
local function UpdateCamera()
if humanoid and playerRoot then
camera.CFrame = CFrame.new(playerRoot.Position, LookAtPart.Position)
end
end
game:GetService("RunService").RenderStepped:Connect(UpdateCamera)
end
end
end
end
end)