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

Would I use MakeJoints() ?

Asked by
Codebot 85
9 years ago

Alright so I'm trying to make my ROBLOXian have a certain arm angle, 2 seconds after I join the game. The problem is It's not staying connected to the character. I've tried to anchor it, but it just falls off the map. How Would I make it stick to my player?

The script is inside of StarterPack:

wait(2)
x = script.Parent.Parent.Name
player = game.Workspace:FindFirstChild(x):GetChildren()
if player ~= nil then
for i = 1,#player do
    if player[i]:IsA("Part") then
        if player[i].Name == "Left Arm" then
    player[i].Position = Vector3.new (-0.699999928, 3.4000001, -0.699999988)
    player[i].Rotation = Vector3.new (90.0000076, 1.67182443e-005, 45)
    end
    end
end
end

1 answer

Log in to vote
0
Answered by 9 years ago

Problems

  • No need for the get children and everything
  • Use CFrame, don't change the position.

Just go get the left arm like you usually would:

    local x = script.Parent.Parent.Name
    game.Workspace:FindFirstChild(x)["Left Leg"]
    game.Workspace:FindFirstChild(x):FindFirstChild("Left Leg")
    game.Workspace:FindFirstChild(x):WaitForChild("Left Leg")

CFrame and CFrame.Angles

Use CFrame instead of changing the Position and rotation.

part.CFrame = CFrame.new(0,10,0) * part.CFrame.Angles(0,0,math.rad(90))


Final Product

wait(2)
local player = script.Parent.Parent.Character --If script.Parent.Parent is a player, we can get the character by doing ".Character".
local arm = player["Left Leg"]
arm.CFrame = CFrame.new(-0.699999928, 3.4000001, -0.699999988) * CFrame.Angles(math.rad(90.0000076), math.rad(1.67182443e-005), math.rad(45))
--arm.Anchored = true --Do this if the arm falls off...



Hope it helps!

Ad

Answer this question