A ClickDetector supplies a Player Clicked parameter; the Player Object is automatically received, using Player.Parent will reference the "Players" container.
Lastly, if no exceptions were risen to the faulty allocations, it may imply the use of a LocalScript. These programs are only functional in localized environments. Naturally, a ClickDector is only operable in workspace (a globally shared environment) therefore a Server-orientated Script must be used.
local VentEntrance = workspace.VentEntrance
local BackToHallway = VentEntrance.BackToHallWay
local ClickDetector = script.Parent
local function OnClick(PlayerClicked)
local Character = PlayerClicked.Character
if (Character and Character.PrimaryPart) then
local TeleportCFrame = CFrame.new(BackToHallway.Position)
Character:SetPrimaryPartCFrame(TeleportCFrame)
end
end
ClickDetector.MouseClick:Connect(OnClick)
1 comment
Try to add a print before you say local plr. Just to check if this event is actually being run. And after you say CFrame.new(that whole line), add another print to check that the event is working or not.