No problem! Well, i’m saying that your current server script, this one :
local location = script.Parent.Location
local teleporter = script.Parent.Teleporter
teleporter.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
hit.Parent.HumanoidRootPart.CFrame = location.CFrame + Vector3.new(0,3,0)
hit.Parent.HumanoidRootPart.Rotation = Vector3.new(0,0,0)
end
end)
you can replace it by this one :
local location = script.Parent.Location
local teleporter = script.Parent.Teleporter
local remoteEvent = game.ReplicatedStorage.RemoteEvent -- !! In this line : replace "game.ReplicatedStorage.RemoteEvent" with the location of the remote event, example : game.ReplicatedStorage.RemoteEvent. In this example, the remote event is located in ReplicatedStorage.
teleporter.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
local plrWhoTouched = game.Players:GetPlayerFromCharacter(hit.Parent) -- get the player who touched the part
remoteEvent:FireClient(plrWhoTouched) -- this line sends a code execution request to the client-side
end
end)
In this code, replace “game.ReplicatedStorage.RemoteEvent” with the location of the remote event, example : game.ReplicatedStorage.RemoteEvent.
Then, in a localscript (you can place it in “StarterPlayer.StarterCharacterScripts”), paste this code :
local remoteEvent = game.ReplicatedStorage.RemoteEvent -- replace "game.ReplicatedStorage.RemoteEvent" with the same path you used in your server-side script
local plr = game.Players.LocalPlayer
local character = plr.Character
local humanoidRootPart = character.PrimaryPart
local camera = workspace.CurrentCamera
local offset = Vector3.new(0, 0, -10) -- the distance between the camera and the character
local connection
remoteEvent.OnClientEvent:Connect(function() -- when the server-side code execution request is called, it executes the code below:
camera.CameraType = Enum.CameraType.Scriptable
connection = Game:GetService("RunService").RenderStepped:Connect(function() -- this function rotate the camera and make it always follow the character
camera.CFrame = CFrame.new(humanoidRootPart.Position + offset, humanoidRootPart.Position) * CFrame.Angles(0, 0, math.rad(180))
end)
end)
-- to disable the rotation effect, you can use "connection:Disconnect()" and set the camera mode back to "Custom" with another remote event
This code makes your camera rotate while following your character. That works with the RenderStepped
function, which executes the code every frame.
I hope this helps!