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

How can I rotate something welded to the player?

Code:

workspace.ChildAdded:Connect(function(obj)
    wait(1)
    if obj:FindFirstChild("Humanoid") then
        local gun = script.gun:Clone("Gun")
            gun.Parent = obj
        local weld = Instance.new("Weld")
        
        weld.Parent = gun
        weld.Part0 = gun
        weld.Part1 = obj:WaitForChild("Torso")
        
        weld.C0 = obj.Torso.CFrame + Vector3.new(0.6,0.4,0.6)
        weld.C1 = obj.Torso.CFrame

    gun.CFrame = gun.CFrame * CFrame.Angles(math.pi / 2, 0, 0)
    end
end)

Result: https://gyazo.com/bf7a240ac09dc69d0242af05f9b12462

Am I missing something obvious?

I'm new to CFrames. I just want the gun to be rotated so its facing down.

4 comments

0

You cant without moving what it is welded to

0

So then how do I make it so the gun is facing down?

0

It is possible, just dont inverse the rotation.

0

I don't think I understand. Is there some wiki article that can help me or something

1 answer

You could change the C0 or C1 properties of the weld to rotate and move the gun.

It might seem complicated but as far as i know it is one of the easiest methods there is.

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