Script problem part

script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
wait(2) – add a two-second delay
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(46, 60.25, -110.669)
end
end)

How do I make it so the player has to be in the part for it to occur since I
get stuck in a teleportation loop

1 Like

you this script

local Touched  = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) and not touched then
touched = true
wait(2) – add a two-second delay
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(46, 60.25, -110.669)
touched = false
end
end)

1 Like

You thank you. You how learn these make thing code

as you develop games, or do some simple stuffs… you get it.

it is not working. I do not know why

can you specify what you want to achieve so that I can give the best solution

(“Humanoid”) and not touched then this whole part is red

“touched” after “and not” should be uppercase: “Touched” on the third line

it still doesn’t work. I do not know why.

this whole thing is underlined: (“Humanoid”) and not Touched then
touched

This would work

local part = script.Parent
local Debounce = false

part.Touched:Connect(function(hit)
	local Character = hit.Parent
	local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
	if not Player then return end
	if not Debounce then
		Debounce = true
		Character:PivotTo(CFrame.new(46, 60.25, -110.669))
		task.wait(2)
		Debounce = false
	end
end)

But it is working Only the time is broken. I was trying i was attempting fix that.

Try this script

local teleportPart = -- insert the part you want to teleport the player to

function onTouched(part)
    local humanoid = part.Parent:FindFirstChild("Humanoid")
    if humanoid then
        local character = humanoid.Parent
        if character then
            local humanRootPart = character:FindFirstChild("HumanoidRootPart")
            if humanRootPart then
                -- check if the player is touching the teleportPart
                if part == teleportPart then
                    -- teleport the player to the desired location
                    humanRootPart.CFrame = -- insert the desired location
                end
            end
        end
    end
end

teleportPart.Touched:Connect(onTouched)

it’s pretty simple, see the variable name called Touched? the others are misspelled because they don’t have an uppercase letter. Lua is case-sensitive when it comes to variables, so it won’t be able to run because it’s trying to check the value of a different value.