I’m new to scripting and I’m practicing camera manipulation. My goal is to have the local player’s camera focus on a part after triggering the proximity prompt attached to it. I didn’t get any exceptions while running the game but my script isn’t working.
Server Script:
local r_storage = game:GetService("ReplicatedStorage")
local switch = r_storage.forCamera.RemoteFunctions.Switch
local object = script.Parent
object.Attachment.ProximityPrompt.Triggered:Connect(function(player)
switch:FireClient(player, object)
end)
Local Script:
local player = game:GetService("Players").LocalPlayer
local humanoid = player.CharacterAdded:wait():WaitForChild("Humanoid")
local r_storage = game:GetService("ReplicatedStorage")
local switch = r_storage.forCamera.RemoteFunctions.Switch
local camera = workspace.CurrentCamera
switch.OnClientEvent:Connect(function(object)
if humanoid.Health > 0 then
camera.CameraType = Enum.CameraType.Scriptable
camera.Focus = object.CFrame
end
end)