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

How do i get ONLY 1 player's camera to change?

Asked by 7 years ago
Edited 7 years ago

I've created a camera script that changes the players camera to rotate around a brick, but for some reason, when someone touches the specific brick, it is changing every players camera to rotate around the brick.

It is meant to only work for the person that touched the brick.

The camera script is located in Game/StarterGui/CameraScript(script)

IT IS a local script. Filtering Enabled is NOT on.

local player = game.Players.LocalPlayer
local Hub = game.Workspace.Hub





game.Workspace.Finish.Touched:connect(function(Brick)


    local Player = Brick.Parent:findFirstChild("Humanoid")
        Player.Parent.Torso.CFrame = CFrame.new(Hub.Position+Vector3.new(0, 3, 0))


game.Workspace.CurrentCamera.CameraSubject = game.Workspace.FocusHere
game.Workspace.CurrentCamera.CameraType = "Custom"


local finished = false

local Angle = 0

local Position = 0

game.Players.LocalPlayer.CameraMaxZoomDistance = 20
game.Players.LocalPlayer.CameraMinZoomDistance = 20
game.Players.LocalPlayer.PlayerGui.RotateScreenAbility.Frame.Visible = true

while finished == false do
game.Workspace.CurrentCamera.CoordinateFrame = game.Workspace.FocusHere.CFrame * CFrame.Angles(0, Angle, Angle) * CFrame.new(Position, Position, Position)
    Angle = Angle + math.rad(1)
    Position = Position + .08
    wait(.001)
    end

wait(5)


game.Workspace.CurrentCamera.CameraSubject = player.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Follow"


end)

Please help ASAP!

0
Plz help D: GammaShock 32 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Check if the part that touched the brick is a member of the player's Character

We can do this with the :IsDescendantOffunction.

Example,

local player = game.Players.LocalPlayer
local Hub = game.Workspace.Hub
local char = plr.Character or plr.CharacterAdded:wait()

game.Workspace.Finish.Touched:connect(function(Brick)
    if Brick:IsDescendantOf(char) then
        local Player = Brick.Parent:findFirstChild("Humanoid")
            Player.Parent.Torso.CFrame = CFrame.new(Hub.Position+Vector3.new(0, 3, 0))


    game.Workspace.CurrentCamera.CameraSubject = game.Workspace.FocusHere
    game.Workspace.CurrentCamera.CameraType = "Custom"


    local finished = false

    local Angle = 0

    local Position = 0

    game.Players.LocalPlayer.CameraMaxZoomDistance = 20
    game.Players.LocalPlayer.CameraMinZoomDistance = 20
    game.Players.LocalPlayer.PlayerGui.RotateScreenAbility.Frame.Visible = true

    while finished == false do
    game.Workspace.CurrentCamera.CoordinateFrame = game.Workspace.FocusHere.CFrame * CFrame.Angles(0, Angle, Angle) * CFrame.new(Position, Position, Position)
        Angle = Angle + math.rad(1)
        Position = Position + .08
        wait(.001)
        end

    wait(5)


    game.Workspace.CurrentCamera.CameraSubject = player.Character.Humanoid
    game.Workspace.CurrentCamera.CameraType = "Follow"

    end
end)

Just a test

Good Luck!

0
THANKS! GammaShock 32 — 7y
0
No problem :3 User#11440 120 — 7y
0
Although, to get the script to work, "then" and "if" had to be taken out GammaShock 32 — 7y
Ad

Answer this question