I want to move a camera to a certain position when a gui is clicked
local cameras = game.Workspace.Cameras:GetChildren()
game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function (player, area)
if area < #cameras then
return cameras[area+1].Position
end
end
local leftbutton = script.Parent
local area = 1
leftbutton.MouseButton1Click:Connect(function()
local returnedvalue = game.ReplicatedStorage.RemoteFunction:InvokeServer(area)
print(returnedvalue)
end)
I want the camera to move to ‘returnedvalue’ but camera doesnt work
(IT SHOULD BE A LOCAL SCRIPT INSIDE STARTER PLAYER SCRIPTS)
local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera
local Gui = Player.PlayerGui:WaitForChild("Camera")
local Point = game.Workspace.CameraPoint
local Enabled = false
Gui.TextButton.MouseButton1Up:Connect(function()
if Enabled then
repeat Camera.CameraType = Enum.CameraType.Custom
until Camera.CameraType == Enum.CameraType.Custom -- Makes it Normal
Enabled = false
else
repeat Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable -- Makes Camera Scriptable
Camera.CFrame = Point.CFrame -- Changes the position to parts CFrame
Enabled = true
end
end)
You can check if it works and also if you know how to use tween then You can use it on here as well.
Mark me as Solution