Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does my click teleporter do nothing when I click on it?

This script does literally nothing. No errors show up from it either. The function runs and shows up that it ran in the output. Why is this happening? Script:

script.Parent.MouseClick:Connect(function(click)
	local plr = game.Players:GetPlayerFromCharacter(click.Parent)
	plr.Character.Torso.CFrame = CFrame.new(game.Workspace.VentEnterance.BackToHallway.Position)
end)

Edited.

1 comment

0

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.

1 answer

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.

--###----------[[Regular Script, within the ClickDetector]]----------###--

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

0

So, this is in a regular script, in a model in the workspace. I used the script you just gave me, and it does nothing.

This discussion is preserved as it was. New answers, comments, and votes are closed.