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 6 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:

01script.Parent.Touched:Connect(function(part)
02local huma = part.Parent:FindFirstChild("Humanoid")
03local dbo = false
04local placeone = CFrame.new(-260, 1.5, -278)
05 
06if huma then
07   print("humanoid found")
08   dbo = true
09   if dbo == true then
10        huma.Torso.CFrame = placeone
11        dbo = false
12end
13end
14end)

Can you help me?

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

1 answer

Log in to vote
3
Answered by 6 years ago
Edited 6 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.

01script.Parent.Touched:Connect(function(part)
02    local huma = part.Parent:FindFirstChild("Humanoid")
03    local dbo = false
04    local placeone = CFrame.new(-260, 1.5, -278)
05    if huma then
06        print("Humanoid Found")
07        dbo = true
08        if dbo == true and part.Parent:FindFirstChild("Torso") then -- check for torso
09            part.Parent:FindFirstChild("Torso").CFrame = placeone -- if you want this to work with R15 change Torso to LowerTorso
10            dbo = false
11        end
12    end
13end)
Ad

Answer this question