Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is the camera not rotating?

Asked by 8 years ago
local changecam = game.Workspace.Change
local touched = false
-- ================================================================

-- // Camera Variables

local CamOffset = Vector3.new(0, 5.5, 20)
local CamLookDirection = Vector3.new(0, 0, -1)
local angle = 0

local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local RunService = game:GetService('RunService')


-- ================================================================


changecam.Touched:connect(function(hit)
    if not touched then

        touched = true
        wait(1)
        print("I touched it!")
         local function setupCamera()
            camera.CoordinateFrame = CFrame.new(player.Character.HumanoidRootPart.Position + CamOffset,
                             player.Character.HumanoidRootPart.Position + CamOffset + CamLookDirection)
        end 

        player.CharacterAdded:connect(setupCamera)
        print("1")

          local function onUpdate()
            if player.Character and player.Character:FindFirstChild('HumanoidRootPart') then
        camera.CoordinateFrame = camera.CoordinateFrame:lerp(
                                 CFrame.new(player.Character.HumanoidRootPart.Position + CamOffset,
                                 player.Character.HumanoidRootPart.Position + CamOffset + CamLookDirection), 0.2 )
        print("Trying to rotate")    
    for i = 1, 90 do
        wait()
        camera.CFrame = camera.CFrame * CFrame.Angles(0,i,0)
    end
        end
    end
        RunService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, onUpdate)
    print("2")

        touched = false     

    end
end)

I want to make touched parts to make rotate the user's camera when he touches a specific part. But for some reason the camera doesn't rotate at all.

0
Why do you have an onUpdate function that is never called? XAXA 1569 — 8y
0
Sorry, forgot to put the line 43. I did a bad paste, but it still doesn't work. iDarkGames 483 — 8y

Answer this question