When I parent a weld, the player’s position changes by about 3 studs each time.
Here is my code(the prints are the player’s position throughout the code):
local function showKillzone(target)
if target.Parent:FindFirstChild("Humanoid") then
if selectedTarget == target.Parent then return end
if selectedTarget then
removeSelected()
end
local player = Players:GetPlayerFromCharacter(target.Parent)
if not player then return end
print(player.Name)
--[[local rankInGroup = player:GetRankInGroup(groupID)
local studSize = getKillzoneStudSize(rankInGroup)
if not studSize then return end
print(studSize)--]]
local char = target.Parent
local weld = Instance.new("Weld")
local HRP = char:FindFirstChild("HumanoidRootPart")
if not HRP then return end
local clone = Parts.Killzone:Clone()
print(HRP.Position)
clone.CanCollide = false
clone.CanTouch = false
--clone.Size = Vector3.new(studSize, killzoneThickness, studSize)
print(HRP.Position)
clone.Size = Vector3.new(7, killzoneThickness, 7)
clone.CFrame = HRP.CFrame
clone.Parent = char
print(HRP.Position)
weld.Part0 = clone
weld.Part1 = HRP
print(HRP.Position)
weld.C0 = clone.CFrame
weld.C1 = HRP.CFrame * CFrame.new(0, -2.75, 0)
print(HRP.Position)
weld.Parent = char --For some reason this line needs fixing
print(HRP.Position)
selectedTarget = target.Parent
else
if selectedTarget and workspace:FindFirstChild(selectedTarget.Name) then
removeSelected()
end
end
end
And here is what the print statement is
Line 96 is line weld.Parent = char
.