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

How do I make a camera change for a specified player?

Asked by
vxnnisu 17
2 years ago
Edited 2 years ago

Hello. I'm making a hangout game, and I'm trying to make the camera move to a more cinematic angle. It works, but when you sit down, the camera moves for everyone, I've been researching for 2 days, and nothing has seemed to work. I just need some help on how to make the camera move for only you.

Here's the code that is inside the seat (normal script)

local seat = script.Parent
function added(child)
    if (child.className=="Weld") then
        local human = child.part1.Parent:FindFirstChild("Humanoid")
        game.ReplicatedStorage.camdesksit:FireAllClients()
        if human ~= nil then
            anim = human:LoadAnimation(seat.sitanim)
            anim:Play()
        end
     end
end

function removed(child2)
    if anim ~= nil then
        game.ReplicatedStorage.camoff:FireAllClients()
        anim:Stop()
        anim:Remove()
    end
end

seat.ChildAdded:connect(added)
seat.ChildRemoved:connect(removed)

And here is the localscript inside StarterGui:

local player = game.Players.LocalPlayer
local character = player.Character
local camera = game.Workspace.CurrentCamera

game.ReplicatedStorage.camwallsit.OnClientEvent:Connect(function()
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CFrame = workspace.wallsit.wallsitcamera.CFrame
end)

game.ReplicatedStorage.camdesksit.OnClientEvent:Connect(function()
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CFrame = workspace.desksit.desksitcamera.CFrame
end)

game.ReplicatedStorage.camoff.OnClientEvent:Connect(function()
    workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
end)

There is three RemoteEvents: One for the sitting on the wall, one for sitting at a desk, and one for standing up.

Thank you, and I appreciate your help.

0
Try changing :FireAllClients() to :FireClient() and specifying the player that is sitting down. SitaruDaniel 44 — 2y
0
Thanks so much. vxnnisu 17 — 2y

Answer this question