So i want to set the players current camera when a proximity prompt is interacted with, i currently have these two codes, the second one is in starter player scripts
local prompt = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChangeCameraEvent = ReplicatedStorage:WaitForChild("RemoteEvents").ChangePlayersCamera
prompt.Triggered:Connect(function(player)
local targetCamera = script.Parent.Parent.Parent.Parent.EggView
if targetCamera and targetCamera:IsA("Camera") then
ChangeCameraEvent:FireClient(player, targetCamera)
else
warn("TargetCamera not found or is not a Camera!")
end
end)```
```lua
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
local ChangeCameraEvent = ReplicatedStorage:WaitForChild("RemoteEvents").ChangePlayersCamera
ChangeCameraEvent.OnClientEvent:Connect(function(targetCamera)
print("Camera Change Event Runned")
if targetCamera and targetCamera:IsA("Camera") then
camera.CameraType = Enum.CameraType.Scriptable
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local tween = TweenService:Create(camera, tweenInfo, {
CFrame = targetCamera.CFrame
})
tween:Play()
else
warn("Invalid camera received! ", targetCamera)
end
end)
