Teleporting Problem

I’m trying to make a teleport part that works when touched while sitting down.
I had no errors in the output, and I even searched for an answer. I tried different solutions by using Humanoid.Sit = false which didn’t really help.

``function onTouched(m)

local p = m.Parent:findFirstChild(“Humanoid”)

if p ~= nil then
	p.Humanoid.Sit = false
	p.Torso.CFrame = CFrame.new(-231.786, 1, 28.401)
	end
end

script.Parent.Touched:connect(onTouched)

it’s messed up lol
do this instead

if p ~= nil then
	p.Sit = false
	m.Parent.HumanoidRootPart.CFrame = CFrame.new(-231.786, 1, 28.401)
	end
end

use

p.HumanoidRootPart.CFrame = CFrame.new(-231.786, 1, 28.401)

This works but it wont teleport when the player is sitting.

Just simply check if there’s a Player Object, if there is create a Character variable referencing the m’s Parent:

local function onTouched(m)
    if game.Players:GetPlayerFromCharacter(m.Parent) then
        local Character = m.Parent
        Character.Humanoid.Sit = false
        Character.Torso.CFrame = CFrame.new(-231.786, 1, 28.401)
    end
end

script.Parent.Touched:Connect(onTouched)

Its Find not find, coding is cap sensitive

Didn’t realized that error, thanks telling me!

try adding a wait function like this:

function onTouched(m)

	local p = m.Parent:FindFirstChild(“Humanoid”)

	if p ~= nil then
		p.Humanoid.Sit = false
		wait()
		p.HumanoidRootPart.CFrame = CFrame.new(-231.786, 1, 28.401)
	end
end
script.Parent.Touched:connect(onTouched)

Did mine work? you never said anything about it

Oh sorry that I didn’t reply back, The script didn’t work.

Still didn’t work I also tried to switch it up a bit when it didn’t work.

function onTouched(hit)

local humanoid = hit.Parent:FindFirstChild(“Humanoid”)

if humanoid ~= nil then
	humanoid.Sit = false
	hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-231.786, 1, 28.401)
	end
end
script.Parent.Touched:connect(onTouched)

Just gonna yeet this here oof a

-- Teleport when sitting
script.Parent.Touched:Connect(function(hit)
	local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if Player then
		local Humanoid = hit.Parent:FindFirstChild("Humanoid")
		local HRP = hit.Parent:FindFirstChild("HumanoidRootPart")
		if Humanoid then
			if Humanoid.Sit then
				HRP.CFrame = CFrame.new(0, 100, 0)
			end
		end
	end
end)


-- Teleport & make them sit
script.Parent.Touched:Connect(function(hit)
	local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if Player then
		local Humanoid = hit.Parent:FindFirstChild("Humanoid")
		local HRP = hit.Parent:FindFirstChild("HumanoidRootPart")
		if Humanoid then
			Humanoid.Sit = true
			HRP.CFrame = CFrame.new(0, 100, 0)
		end
	end
end)

Still doesn’t work, it still won’t teleport when the player is sitting.

I also tried your’s and it still doesn’t work I also tired to change it a bit when it didn’t work.

Ok i think the only choice here is DEBUGGING
spam those prints

function onTouched(hit)
print("touched")
local humanoid = hit.Parent:FindFirstChild(“Humanoid”)

if humanoid ~= nil then
print("humanoid found")
	humanoid.Sit = false
print("stop sitting")
	hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-231.786, 1, 28.401)
print("teleported")
	end
end
script.Parent.Touched:connect(onTouched)

Can you add print statements to check what & what doesn’t work? Also you should be using a regular Script if you haven’t done so already

I didn’t get any errors from the output It didn’t teleport me when sitting.

try mine and tell me what it printed