Boombox welding problem

I made a Boombox tool that welds to player’s Torso’s back when activated but im experiencing the welding problem.When welded, it slides slightly to the side. after many attempts,it slides even many more.

The script that i made by myself:

local tool = script.Parent
local boombox = tool.Handle

tool.Activated:Connect(function()
	local plr = game.Players:GetPlayerFromCharacter(tool.Parent)
	if boombox then
		local newmodel = boombox:Clone()
		newmodel.Name = "Boombox"
		newmodel.Parent = plr.Character
		newmodel.CFrame = plr.Character.UpperTorso.CFrame
		local weld_constraint = Instance.new("WeldConstraint",plr.Character.UpperTorso)
		weld_constraint.Part0 = weld_constraint.Parent
		weld_constraint.Part1 = newmodel
		weld_constraint.Parent = plr.Character.UpperTorso
		newmodel.Position = newmodel.Position - Vector3.new(0.8,0,0)
		wait(0.25)
		newmodel.Rotation = newmodel.Rotation + Vector3.new(0,180,45)
		plr.PlayerGui.Buttons.Boombox.Visible = true
		tool:Destroy()
	end
end)

I have tried searching this issue but i still couldn’t reached my goal.
What should i do?

You can add a little bit more where you set the CFrame, that way your offset and rotation are included.

local tool = script.Parent
local boombox = tool.Handle
local offset =  CFrame.new(-0.8,0,0)
local rotation = CFrame.Angles(0,math.rad(180),math.rad(45))

tool.Activated:Connect(function()
	local plr = game.Players:GetPlayerFromCharacter(tool.Parent)
	if boombox then
		local newmodel = boombox:Clone()		
		newmodel.Name = "Boombox"		
		newmodel.CFrame = plr.Character.UpperTorso.CFrame * offset * rotation
		
		local weld_constraint = Instance.new("WeldConstraint",plr.Character.UpperTorso)
		weld_constraint.Part0 = weld_constraint.Parent
		weld_constraint.Part1 = newmodel
		
		newmodel.Parent = plr.Character		

		tool:Destroy()
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.