Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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!

1 comment

0

Plz help D:

1 answer

✓ Accepted answer

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!

3 comments

0

THANKS!

0

No problem :3

0

Although, to get the script to work, "then" and "if" had to be taken out

This discussion is preserved as it was. New answers, comments, and votes are closed.