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)
✓ ANSWER ACCEPTED
How to make ".Touched" not touch yourself?
1 answer
✓ Accepted answer
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.
