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

I need a way to make a local camera for each player. How would I go about doing that?

Asked by 4 years ago

I do understand that there is a default camera, but I am making a cut-scene for games, and every time one player steps on the activation brick, everyone goes through the cut-scene.. Can I get help with this problem? Here is the script:

wait(3)
local TweenService = game:GetService("TweenService")
local Camera = game.Workspace.CurrentCamera

local function MoveCamera(StartPart, EndPart, Duration, EasingStyle, EasingDirection)
    Camera.CameraType = Enum.CameraType.Scriptable
    Camera.CFrame = StartPart.CFrame
    local Cutscene = TweenService:Create(Camera, TweenInfo.new(Duration, EasingStyle, EasingDirection), {CFrame = EndPart.CFrame})
    Cutscene:Play()
    wait(Duration)
end
local function Cutscene()
    MoveCamera(game.Workspace.Camera, game.Workspace.PartA, 1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
    MoveCamera(game.Workspace.PartA, game.Workspace.PartA, 0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
    MoveCamera(game.Workspace.PartA, game.Workspace.PartB, 1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
    MoveCamera(game.Workspace.PartB, game.Workspace.PartB, 0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
    MoveCamera(game.Workspace.PartB, game.Workspace.PartC, 1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
    MoveCamera(game.Workspace.PartC, game.Workspace.PartC, 0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
    MoveCamera(game.Workspace.PartC, game.Workspace.PartD, 1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
    MoveCamera(game.Workspace.PartD, game.Workspace.PartD, 0.2, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
    wait(.5)
    Camera.CameraType = Enum.CameraType.Custom
    Camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
    end
    local enabled = false
workspace.brick.Touched:Connect(function(plr)
    if enabled == true then return end enabled = true
    plr.Parent.Humanoid.WalkSpeed = plr.Parent.Humanoid.WalkSpeed == 0
    plr.Parent.Humanoid.JumpPower = plr.Parent.Humanoid.WalkSpeed == 0
Cutscene()
plr.Parent.Humanoid.WalkSpeed = 16
plr.Parent.Humanoid.JumpPower = 50
wait(2)
enabled = false
end)

Thank you to anyone who can help me with this!

0
I assume this script is a LocalScript, yes? If so then the fix is simple, just replace "plr.Parent" in the "workspace.brick.Touched" connection to "game.Players.LocalPlayer.Character". This will make all players animate their own camera, even if they didn't touch the part. If it's not a LocalScript, get back to me. SuperMario9595 150 — 4y
0
the script does work, just not the way i want it to. I want it to display on one players screen. peytonallen920 66 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Here's the solution:

Add an if statement to the start of the touch fuction checking if who touched the part has the same name of the local player, if yes, run your code, else do something that you want or just dont. Also add a local variable called player and assign it to the local player.

The function would look like this:

local player = game:GetService("Players").LocalPlayer

workspace.brick.Touched:Connect(function(plr)
    if player.Name == plr.Parent.Name then
        if enabled == true then return end enabled = true
            plr.Parent.Humanoid.WalkSpeed = plr.Parent.Humanoid.WalkSpeed == 0
            plr.Parent.Humanoid.JumpPower = plr.Parent.Humanoid.WalkSpeed == 0
        Cutscene()
        plr.Parent.Humanoid.WalkSpeed = 16
        plr.Parent.Humanoid.JumpPower = 50
        wait(2)
        enabled = false
        end
    end
end)

Sorry for the late response!

0
it worked! thank you! i needed to remove one of the ends, though. peytonallen920 66 — 4y
Ad

Answer this question