Camera Position When Click UI

Is there a way when you click a UI it makes it so your in a camera?

2 Likes

Not sure what you mean, do you want the player’s camera to be moved when they click on a GuiObject button?

local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

local Button = script.Parent
local Part = workspace:WaitForChild("Part")
local Camera = workspace.CurrentCamera

Button.MouseButton1Click:Connect(function()
	Camera.CameraSubject = Part
	task.wait(5)
	Camera.CameraSubject = Humanoid
end)

Here’s a simple script which will make the camera focus on a part in the workspace when the MouseButton1Click event is fired for a GuiObject button.

1 Like

Let me explain, you have 3 diffrent cameras. When you go into a part a ui shows up and you can switch through 3 different cameras.

1 Like

I provided a simple script which you should be able to use to achieve the desired result.


how would u set it up

1 Like

You should use Local Scripts when dealing with Guis.

2 Likes

1 Like

thanks for helping me out! are credits needed?

put in a localScript:

local tweenService = game:GetService("TweenService")
local tinfo = tweenInfo.new(0)

function setCamera(obj)
if obj then
local goal = {CFrame = obj.CFrame;}
local currentCam = workspace.currentCamera

currentCam.CameraType = Enum.CameraType.Scripteable;
currentCam.CameraSubject = obj

local tween = tweenService:Create(currentCam,tinfo,goal)
tween:Play()
end
end

what does this do. Does it do the same?