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

How to rotate an accesory?

Hello. I'm trying to make a backpack that should stay behind the player's torso (using R6).

Here's the script:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local backpack = game.ServerStorage.Backpack
		
		backpack:Clone().Parent = char
		local torso = char.Torso		
		
		local weld = Instance.new("WeldConstraint", backpack)
		weld.Part0 = torso
		weld.Part1 = backpack.Handle
	end)
end)

Problem The backpack won't rotate so that it stays on the player's back, instead it looks like this:

Photo

1 answer

✓ Accepted answer

You need to modify the CFrame of the weld. In your case (and I think most cases), you want to modify weld.C0(CFrame0, like Part0). Because your backpack's back-to-front, you want to rotate it 180 degrees on the Y axis. If you're familiar with CFrames, you can probably do this yourself, but in case not, you'll want to use CFrame.Angles like so: weld.C0 = weld.C0 * CFrame.Angles(0, math.rad(180), 0) If you need to reposition it, add a Vector3 value: weld.C0 = weld.C0 + Vector3.new(x, y, z)

EDIT: Sorry - I didn't notice you were using a WeldConstrains as opposed to a regular weld. If it's the same to you, just use a regular weld, as you can set the CFrame for them.

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