How to move Player camera

  1. Goal
    Whenever player clicks some button, its camera should get moved to some location.
  2. Issue
    CameraOffset doesnt work. Can anyone tell me why?
local plr = game.Players.LocalPlayer;
local gui = plr.PlayerGui;
local character = plr.Character;
local humanoid = character:WaitForChild("Humanoid");
local landTerraformationButton =gui.ScreenGui:WaitForChild("TerraformButton");
local upButton = gui.ScreenGui:WaitForChild("UpTerraform");
local downButton =gui.ScreenGui:WaitForChild("DownTerraform");


landTerraformationButton.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.LandTerra:Fire(humanoid);
	upButton.Visible = not upButton.Visible
	downButton.Visible = not downButton.Visible
end)

game.ReplicatedStorage.LandTerra.Event(function(humanoid)
	humanoid.CameraOffset = Vector3(1,1,1);
end)
1 Like

Instead of using CameraOffset, use the camera inside of Workspace.

I think you can tween the Camera’s CFrame to another part’s CFrame, im not to familiar at the moment.

I’ll see if I can create an example in a bit.

will it move camera for other players as well?

i think you need a remote event to make every player camera move

Yeah, here is the place file for you to check out.

Tell me if this is what you wanted:

cooltweencamera.rbxl (49.4 KB)

If you mean like once the button is clicked, making the camera move for like all the people in the server and not just you, im not sure if that is possible.

oh yeah, here is the fixed code for the local script inside of the button too…

local b = script.Parent
local ts = game:GetService("TweenService")

local rs = game:GetService("RunService")
local plr = game:GetService("Players")

local camera = workspace.CurrentCamera
local truth = true

local connectEvent

b.MouseButton1Down:Connect(function()
	if truth then
		truth = false

		local tween = ts:Create(camera, TweenInfo.new(1), {CFrame = workspace.Part.CFrame})
		tween:Play()
		tween.Completed:Wait()
		print("completed")
		
		coroutine.resume(coroutine.create(function()
			connectEvent = rs.RenderStepped:Connect(function()
				camera.CFrame = workspace.Part.CFrame
			end)
		end))

	end
end)

So its not posible to move only one player`s cameras?

Are you trying to specifically say a different person or you the player itself?
Have you opened the place file yet?

Yes, I opened it. I want that result but only on the player which clicks on that button

So it is not moving the player’s camera to the part for you?

No, I mean something else. when player clicks on the button other players cameras shouldn’t get affected.

Oh alright, I understand. I just did a test with two players in studio, and it only affects one player, which is you. So yeah, the tween will only affect the player’s camera separately, it will not affect others.

Thank you very much! It was helpfull <3

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.