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

Why does this script not work?

Asked by 10 years ago
one = script.Parent.Parent.Part
two = script.Parent.Parent.Part2
thr = script.Parent.Parent.Part3
cd = cd.script.ClickDetector

cd.MouseClick:connect(function()
    one.Position = Vector3.new(66.9, 1.2, -15.6)
    two.Position = Vector3.new(66.9, 1.2, -15.6)
    thr.Position = Vector3.new(66.9, 1.2, -15.6)
        wait(.025)
    one.Position = Vector3.new(66.9, 1.3, -15.6)
    two.Position = Vector3.new(66.9, 1.3, -15.6)
    thr.Position = Vector3.new(66.9, 1.3, -15.6)
            wait(.025)
        one.Rotation = Vector3.new(2,15,10)
        two.Rotation = Vector3.new(8,13,29)
        thr.Rotation = Vector3.new(20,8,9)
            wait(.025)      
end)

The three blocks and button are in a model that is inside of another model. That's why I have Parent twice at the top of the script. Whenever I click the button, nothing happens. There is a click detector inside of the button block. Also, the real thing is 155 lines. I took out most of it so it would fit here with reasonable size. The three blocks move up like 130 times, then they all spin. The same script (but with only one block moving) works fine. There's just something wrong with this one. Can three blocks within the same function move at the same time? Or should I make three different functions of the three different blocks.

4 answers

Log in to vote
0
Answered by 10 years ago

Line 6,

cd.MouseButton1Click:connect(function()
0
That did not work. As before, nothing happened when I clicked it. Lightdrago 95 — 10y
Ad
Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

This isn't a gui, Roboy5857.

Your problem, Lightdrago, was that rotation increments has to be in radians.. You can perform this by using the math.rad method on any number; math.rad(num) or num:rad().

Here are two ways to fix your problem;

--Use CFrame to rotate..

one.CFrame = CFrame.new(one.Position)*CFrame.Angles(math.rad(2),math.rad(15),math.rad(10))
--Or just perform the radians method on the Rotation property..

one.Rotation = Vector3.new(math.rad(2),math.rad(15),math.rad(10)

I suggest the first one, so you can get used to rotating that way as it will come in handy for the knowlage of welds and further CFrame manipulation.

If you have any questions ask me..

Hope I helped

+1

Log in to vote
0
Answered by
Vividex 162
10 years ago

Think you already found your answer, but remember, Vector3 = GUIS, CFrame = Parts

Log in to vote
0
Answered by
lomo0987 250 Moderation Voter
10 years ago
one = script.Parent.Parent.Part
two = script.Parent.Parent.Part2
thr = script.Parent.Parent.Part3
cd = script.Parent.ClickDetector -- This was wrong.. This is now correct if the ClickDetector is located within the part. 

cd.MouseClick:connect(function()
    print("Clicked")
    one.Position = Vector3.new(66.9, 1.2, -15.6)
    two.Position = Vector3.new(66.9, 1.2, -15.6)
    thr.Position = Vector3.new(66.9, 1.2, -15.6)
    print("1")
        wait(.025)
    one.Position = Vector3.new(66.9, 1.3, -15.6)
    two.Position = Vector3.new(66.9, 1.3, -15.6)
    thr.Position = Vector3.new(66.9, 1.3, -15.6)
    print("2")
            wait(.025)
        one.Rotation = Vector3.new(2,15,10)
        two.Rotation = Vector3.new(8,13,29)
        thr.Rotation = Vector3.new(20,8,9)
        print("3")
            wait(.025)      
end)

I added some prints so you can see how it acts when you click it. (Or just incase something was wrong..)

Tbh, I don't really see how they missed line 4..

Answer this question