As the title says, whenever I weld the part to the humanoid, it weirdly causes the player to teleport around. I am attempting to make a hitbox using spatial queries. This is a local script stored in StarterCharacterScripts
local players = game:WaitForChild("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local humanoid = script.Parent:FindFirstChild("Humanoid")
local humanoidRootPart = humanoid.RootPart
local offset = Vector3.new(2,0,0)
local UserInputService = game:GetService("UserInputService")
function newHitbox ()
local weld = Instance.new("WeldConstraint", humanoidRootPart)
local hitbox = Instance.new("Part")
weld.Parent = humanoidRootPart
weld.Part0 = humanoidRootPart
weld.Part1 = hitbox
hitbox.Massless = true
hitbox.Transparency = 0
hitbox.CanCollide = false
hitbox.CanQuery = false
hitbox.Size = Vector3.new(5, 5, 5)
hitbox.Parent = player.Character
hitbox.CFrame = humanoidRootPart.CFrame + humanoidRootPart.CFrame.LookVector * offset.X + Vector3.new(0,offset.Y)
end
I’m a novice at coding, but I’ve looked through other posts here with similar problems, though any solutions don’t seem to work for me. Thank you in advance!