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)