Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Touching part is not teleporting me, why?

Asked by 5 years ago

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?

0
Make a part.Parent variable inside the if statement Oficcer_F 207 — 5y
0
Humanoids don't have a Torso, the Character model does Rare_tendo 3000 — 5y

1 answer

Log in to vote
3
Answered by 5 years ago
Edited 5 years ago

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)
Ad

Answer this question