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

How to make ".Touched" not touch yourself?

Asked by 8 years ago

function onTouch(Part) if Part.Parent:findFirstChild("HumanoidRootPart") then while script do wait() local Root = Part.Parent.HumanoidRootPart Root.CFrame = script.Parent.CFrame*CFrame.new(0,script.Parent.Size.Y/2,0)CFrame.Angles(math.rad(-90),0,0) end end end script.Parent.Touched:connect(onTouch)

1 answer

Log in to vote
1
Answered by 8 years ago

You can't

However, you can use an if statement to make the code stop running after the function is called. A very simple way would be checking if the part's parent's name is the same as your Character's name, like so,

--Regular Script in par in workspace
function onTouch(Part)
    if script.Parent.Name ~= "wfvj014" then-- makes the code not run if your name is wfvj014.
        if Part.Parent:findFirstChild("HumanoidRootPart") then
            while wait() do
                local Root = Part.Parent.HumanoidRootPart
                Root.CFrame = script.Parent.CFrame*CFrame.new(0,script.Parent.Size.Y/2,0)CFrame.Angles(math.rad(-90),0,0)
            end
        end
    end
end
script.Parent.Touched:connect(onTouch)
Make sure to replace wfvj014 with your roblox username

I also changed the while loop a bit because it was annoying me.

Hope I helped.

Good Luck!

If I helped, Don't forget to hit the accept button.
Ad

Answer this question