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

Touching part is not teleporting me, why?

Okay. I made a part, put in it some Particle Emitters and a local script. The part is CanCollide = false, Transparency = 1. This is what's in the local script:

script.Parent.Touched:Connect(function(part)
local huma = part.Parent:FindFirstChild("Humanoid")
local dbo = false
local placeone = CFrame.new(-260, 1.5, -278)

if huma then
   print("humanoid found")
   dbo = true
   if dbo == true then
        huma.Torso.CFrame = placeone
        dbo = false
end
end
end)

Can you help me?

2 comments

0

Make a part.Parent variable inside the if statement

0

Humanoids don't have a Torso, the Character model does

1 answer

✓ Accepted answer

You're trying to get the humanoid's torso, which doesn't exist. The torso is a part of the character model, not the humanoid. (in your script the character is equal to "part.Parent")

To fix this, replace huma.Torso.CFrame = placeone with part.Parent.Torso.CFrame = placeone. However, the torso may not exist (might be R15 or a separate reason) so you need to check for it.

script.Parent.Touched:Connect(function(part)
	local huma = part.Parent:FindFirstChild("Humanoid")
	local dbo = false
	local placeone = CFrame.new(-260, 1.5, -278)
	if huma then
		print("Humanoid Found")
		dbo = true
		if dbo == true and part.Parent:FindFirstChild("Torso") then -- check for torso
			part.Parent:FindFirstChild("Torso").CFrame = placeone -- if you want this to work with R15 change Torso to LowerTorso
			dbo = false
		end
	end
end)

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