Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Welding a model to the player how do I do it?

I created a weld script which welds a model to the player however the model is incorrectly rotated

The rotation I want is a full 270 degrees around

I am using R15 playermodels

local model = script.Parent.Parent
local button = script.Parent
local model1 = model.Quirk:Clone()


button.Touched:connect(function(hit)
	local h = hit.parent:FindFirstChild("Humanoid")
	
	if h then
		local char = hit.Parent
		
		if char:FindFirstChild(model1) ~= true then
			local quirk = model.Quirk:Clone()
			quirk.Parent = char		
			
			for i,v in pairs(quirk:GetChildren()) do -- Weld all parts in the model except the primarypart to the model's primarypart
			    if v:IsA("BasePart") and v ~= quirk.PrimaryPart then
			        local w = Instance.new("Weld", v)
			        w.C0 = (v.CFrame:inverse() * quirk.PrimaryPart.CFrame)
			        w.Part0 = v
			        w.Part1 = quirk.PrimaryPart
			        v.Anchored = false
			        v.CanCollide = false
			    end
			end
	
			quirk:SetPrimaryPartCFrame(char.UpperTorso.CFrame)
			local w = Instance.new("Weld", quirk.PrimaryPart)
			w.Part0 = quirk.PrimaryPart
			w.Part1 = char.UpperTorso
			quirk.PrimaryPart.Anchored = false
			quirk.PrimaryPart.CanCollide = false
		end
	end
end)

1 answer

✓ Accepted answer

You use Welds and you set the HumanoidRootPart to Part0 or Part1.

2 comments

0

I've created a script but now I have another problem.. the models rotation is incorrect

0

Nevermind fixed it

This discussion is preserved as it was. New answers, comments, and votes are closed.