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

Why isn't this working?!

Asked by
rennec 5
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

So I made a morph, and I'm trying to make an onClick GUI that will make a part called "anim" move. Since the part gets welded to the torso in the morph, if I do a regular CFrame it rotates with the torso, moving the whole player with it. So I made this script to do the touch, although it doesn't repeatable rotate, it just turns a little bit once and never does it again when the GUI is clicked. It would be great if you can tell me why this is happening and fix it.

local player = script.Parent.Parent.Parent.Parent.Parent

function onClick(mouse)
    w1 = Instance.new("Weld")
    w1.Parent = player.Character.Chest.anim
    w1.Part0 = w1.Parent
    w1.Part1 = player.Character.Torso
    while true do
    w1.C0.CFrame = w1.C0.Cframe * CFrame.fromEulerAnglesXYZ(0,1,0)
    wait(0.1)
    end
end

script.Parent.MouseButton1Down:connect(onClick)

0
By the way, anim is inside the model called chest if you couldn't already tell. rennec 5 — 9y

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

Your script is erroring. Look at the output when you are trying to figure out what is wrong!

C0 and C1 are CFrame values. They don't have a .CFrame property (even if they did, ROBLOX never capitalizes it as Cframe as you have) -- just C0 and C1 is sufficient.

Also, you can use CFrame.Angles instead of CFrame.fromEulerAnglesXYZ -- it's the same method with a much shorter name.


Note that CFrame.Angles uses radians, not degrees. 1 radian is about 57 degrees, which is probably much more than you want.


Also be warned that this script currently allows the user to click repeatedly, which may have strange effects. You should use some sort of debounce or other pattern to prevent multiple of these while loops from running at the same time.

Ad

Answer this question