I want these parts to change camera position when stepped on.
Whenever I put the parts in different places, they will stop working immediately.
I tried renaming the parts but it didn’t work. I checked if the parts and script were in the correct parent (which they were) and I couldn’t find the problem.
Video showcasing the problem is below. First clip is where the parts was originally placed in and second clip is the parts in a differnet position.
Script: Parent is StarterPlayer → StarterCharacterScripts
local cam = workspace.CurrentCamera
local char = script.Parent
local hrp = char:WaitForChild("HumanoidRootPart")
local cameraOffset = Vector3.new(0, 5, 25)
game:GetService("RunService").RenderStepped:Connect(function()
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = cam.CFrame:Lerp(CFrame.new(hrp.Position + cameraOffset, hrp.Position), 0.1)
end)
workspace.CameraChangePart.Touched:Connect(function(touched)
local humanoid = touched.Parent:WaitForChild("Humanoid")
if humanoid then
cameraOffset = Vector3.new(0, 15, 25)
end
end)
workspace.CameraChangePart2.Touched:Connect(function(touched)
local humanoid = touched.Parent:WaitForChild("Humanoid")
if humanoid then
cameraOffset = Vector3.new(-10, 5, 25)
end
end)