Placing a script inside of a part with a ClickDetector:
local position = CFrame.new(0,0,0);
script.Parent.ClickDetector.MouseClick:Connect(function(player)
player.Character.HumanoidRootPart.CFrame = position;
end)
Replace the CFrame in Position with the position you would like the player to be teleported to.
Nothing would need to be in the output, since it is working as intended. What you need to do is that you need to fire the client (from the script with the ClickDetector in it) on teleport to change the subject of the camera.
Add 1 script which references to the folder (outside of it)
Type:
local Folder = -- reference to folder
local TpParts = Folder:GetChildren()
for i,part in(TpParts) do
part:FindFirstChild("ClickDetector").MouseClick:Connect (function(plr)
plr.Character.HumanoidRootPart.CFrame = part.CFrame
end)
end
Im sorry if thereâs a mistake in the code, Iâm typing it from my cellphone.
Youâll, of course, want to add a RemoteEvent (called CameraEvent in my script) to ReplicatedStorage.
Afterwards, youâll want to place this code inside of each part with a ClickDetector (and change the Position variable accordingly to where that button should send the player).
local position = CFrame.new(0,0,0);
script.Parent.ClickDetector.MouseClick:Connect(function(player)
player.Character.HumanoidRootPart.CFrame = position;
game.ReplicatedStorage.CameraEvent:FireClient(player);
end)