I'm trying to make ClickDetector teleport, but I didn't see any result. Can anyone help me?

Well as you can see im trying to do my best for reach ClickDetector teleport:

  1. I’m making a ClickDetector teleport. Keep it simple and clear!

  2. ? Include screenshots / videos if possible!

  3. I saw that code works with Touched event but didn’t work with ClickDetector. Did you look for solutions on the Developer Hub?

I hope somebody know more codes than me, for see some problem in my code for help me.

-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

According to the developer reference API the click detector event returns a player instance and not the part of the character which is only applicable for Touched events.

Consequently, you can get the player’s character Humanoid root part by getting the players character instead:

local humanoidRootPart = clicked.Character.HumanoidRootPart

ok without the humanoidRootPart variable, everything is alright? Do i have change anything?

You will also have to remove the if statement entirely because click detectors get you the player Instance who clicked.

Screenshot 2020-12-03 at 12.38.03 PM

It’s Parent would be the Players service and as you see there are no Humanoids there so the if statement will always be false and nothing will happen.

ok inside of function do i have to create variables, saying to computer some stuff?

Also next time please use three back ticks``` to format your code like so:

local tele1 = workspace.Tele1
local tele2 = workspace.Tele2


local humanoidRootPart = playerWhoClicked.Character.HumanoidRootPart
humanoidRootPart.Position = tele2.Position


This should do what the code you posted initially should did.

oooooh i did this before but i thought that will not works

local DestinatonPart = workspace.Destination
local Cooldown = 3

local CooldownVar = false
script.Parent.Parent.Color = Color3.fromRGB(0,137,0)
	if CooldownVar then return end
	CooldownVar = true
	script.Parent.Parent.Color = Color3.fromRGB(255,0,0)
	script.Parent.MaxActivationDistance = 0
	local Character = Player.Character
	if Character then
		local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
		if HumanoidRootPart then
			HumanoidRootPart.CFrame = DestinatonPart.CFrame + Vector3.new(0, 10, 0)
	script.Parent.Parent.Color = Color3.fromRGB(0,137,0)
	script.Parent.MaxActivationDistance = 32
	CooldownVar = false

yeah, it works
thank you friend for the patience for teach me, i appreciate

make sure to mark the answer as the solution so other players with a similar problem can find it

1 Like