Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I rotate something welded to the player?

Asked by 5 years ago

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.

0
You cant without moving what it is welded to Fad99 286 — 5y
0
So then how do I make it so the gun is facing down? MakeYourEscape 334 — 5y
0
It is possible, just dont inverse the rotation. mdbaten2 24 — 5y
0
I don't think I understand. Is there some wiki article that can help me or something MakeYourEscape 334 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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.

Ad

Answer this question