Why is that happening (Mini teleport)

Why is that happening?
https://gyazo.com/83a72680d9781c428bdb26b87d65198a

All is working really ok, but i don’t know why im getting a mini teleport when i touch the part to get the Helmet ( You can see that in the gyazo gif )

Already tried to change mass but no changes at all

If you need me to send the script, it’s ok but i don’t think it’s a scripting issue. I will send it here anyway.

-- Global Variable
local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- Just a regular function to check if the player already has the Helmet, so he can't Spam it.
function VerifyHelmet(Char)
	if Char:FindFirstChild("Helmet") then
		return true
	else
		return false
	end
end
-- Function when the player Touches our Invisible Part.
script.Parent.Touched:Connect(function(x)
	if x.Parent and x.Parent:FindFirstChild("Humanoid") then
		if VerifyHelmet(x.Parent) == false then
			-- Variables
			local Humanoid = x.Parent:FindFirstChild("Humanoid")
			local Char = x.Parent
			local Helmet = ReplicatedStorage:FindFirstChild("Helmet"):Clone()
			local Head = Humanoid.Parent.Head
			-- Configuring the Helmet size to all Players head.
			Helmet.Handle.Size = (Head.Size*Helmet.Handle.Size)*1.170
			-- Destroying all others accessorys
			for _,x in pairs(Char:GetChildren()) do
				if x:IsA("Accessory") then
					x:Destroy()
				end
			end
			-- Adding the helmet to the Player
			Humanoid:AddAccessory(Helmet)
			-- Making a ray to find the nearest ceiling
			local Ray = Ray.new(script.Parent.RayPart.Position, Vector3.new(0,100,0))
			local hit, Position = workspace:FindPartOnRay(Ray, Char)
			local magnitude = (Head.Position - Position).magnitude
			-- Part Creation
			local Part = Instance.new("Part", Char)
			Part.Position = Vector3.new(Position)
			Part.Anchored = false
			Part.CanCollide = false
			Part.Size = Vector3.new(0.5,0.5,0.5)
			Part.Material = Enum.Material.WoodPlanks
			Part.Transparency = 1 -- If you want the part to be visible just change that number to 0.
			-- Body Position Creation
			local Bp = Instance.new("BodyPosition", Part); Bp.Name = "BP"
			Bp.Position = Position
			Bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
			-- Rope Creation
			local RopeAttachment = Instance.new("Attachment", Part)
			local Rope = Instance.new("RopeConstraint", Part)
			Rope.Visible = true
			Rope.Attachment0 = RopeAttachment
			Rope.Attachment1 = Head:FindFirstChild("HatAttachment")
			-- How longer is the way to the ceiling will increase the length of the Rope
			Rope.Length = math.floor(magnitude*1.1)	
			-- A while function to update everytime the Player position.
			spawn(function()
				while wait() do
					if Bp and Position then
						Bp.Position = Vector3.new(Head.Position.X, Position.Y, Head.Position.Z)
					end
				end
			end)
		end
	end
end)

A solution since I just analyzed your video further is that the rope simply has a max distance that is too low. If you are 50 studs from the other rope attachment and rope max distance is 25, you can get teleported to be 25 studs away from the other rope attachment since that is the max distance. To fix this before attaching the rope attachment 1 set the maxdistance to (Head.Position - Part.Position).Magnitude which gives the distance between two points. This should work.

Try making the raycast start from the player’s head instead of another part.

Hmm something is telling me its

local Part = Instance.new("Part", Char)
Part.Position = Vector3.new(Position)
Part.Anchored = false
Part.CanCollide = false
Part.Size = Vector3.new(0.5,0.5,0.5)
Part.Material = Enum.Material.WoodPlanks
Part.Transparency = 1 -- If you want the part to be visible just change that number to 0.
-- Body Position Creation
local Bp = Instance.new("BodyPosition", Part); Bp.Name = "BP"
Bp.Position = Position
Bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge)

Parenting a part to the players character and moving it could cause the whole character to move as well
Try commenting out this section and see if your character moves

Imagine if someone just jump in the player head in the right moment that he touched the part, the player would be attached to another player, that’s not what i want.

Thank you so much, what i changed is:

-- Rope Creation
			local RopeAttachment = Instance.new("Attachment", Part)
			local Rope = Instance.new("RopeConstraint", Part)
			Rope.Length = math.floor(magnitude*1.1)	
			Rope.Visible = true
			-- How longer is the way to the ceiling will increase the length of the Rope
			Rope.Attachment0 = RopeAttachment
			delay(0.6,function()
				Rope.Attachment1 = Head:FindFirstChild("HatAttachment")
			end)

And it work’s pretty well now, if you want to see it:

Gif of how it’s working now

1 Like