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

Help with camera position?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

When I touch the part I get a camera view on top of my head. When I die, I want the camera position to go back to the character.

--This is in a normal script in a part named "Camera"
local part = script.Parent --part that will be touched
local remoteEvent = game.ReplicatedStorage.ChangeCameraEvent --Put a RemoteEvent inside of replicatedstorage and name it "ChangeCameraEvent" without qoutes


part.Touched:connect(function(hit)
    local player = game.Players:FindFirstChild(hit.Parent.Name)
    if hit.Parent:FindFirstChild("Humanoid") and player then --hit's parent is a character
        remoteEvent:FireClient(player)
    end
end)

--This is in a local script in Starterpack


local remoteEvent = game.ReplicatedStorage.ChangeCameraEvent
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = game.Workspace:WaitForChild(player.Name)
local rs = game:GetService("RunService")

local studsAboveHead = 20 --studs the camera is above their head

remoteEvent.OnClientEvent:connect(function()

    rs.RenderStepped:connect(function() --That'll run forever. yes
        camera.CameraType = Enum.CameraType.Scriptable
        camera.CoordinateFrame = CFrame.new(character:WaitForChild("HumanoidRootPart").Position + Vector3.new(0.1, studsAboveHead, 0), character:WaitForChild("HumanoidRootPart").Position) * CFrame.Angles(math.rad(180), 0, 0)
    end)
end)

Answer this question