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

I click a block once, it moves, and then the second time it doesn't?

Asked by 4 years ago

Code I have so far:

script.Parent.ClickDetector.MouseClick:Connect(function()
    script.Parent.CFrame = script.Parent.Parent.FrontHood_I.CFrame
    script.Parent.Orientation = ("0, 0, -30")
end)

script.Parent.ClickDetector.MouseClick:Connect(function()
    script.Parent.CFrame = script.Parent.Parent.FrontHood_J.CFrame
    script.Parent.Orientation = ("0, 0, 0") 
end)

Both parts are coded in the same format except different Cframe values and Orientation values. I click the block I want to move once, and yay; it moves to the correct position (position is FrontHood_I's which does not include orientation) and orientation! But I want the block to move back to it's original position, I put in FrontHood_J's Cframe (which is EXACTLY the block's original position) yet for some reason it doesn't move back nor does it rotate back? It's like half of my script works yet the other half is just, well - BROKEN!!

If nothing can fix this, my last resort is to use a wait and debounce, which I really DO NOT want to use. Please help!

0
it is because you are setting it to a position, try script.Parent.CFrame = script.Parent.CFrame + CFrame.new(script.Parent.Parent.FrontHood_J.CFrame) greatneil80 2647 — 4y
0
scary TheluaBanana 946 — 4y
0
also i assume this is on a car, using orientation will rotate it relative to the map, so if you rotate your car the hood rotation won't match up. Try using CF.Angles instead. part.CFrame = part.CFrame * CFrame.Angles(0,math.rad,0) Yishles 4 — 4y

1 answer

Log in to vote
0
Answered by
mc3334 649 Moderation Voter
4 years ago

When setting orietation, you cant just say (0,0,0), you need to use Vector3.new(0,0,0) as XYZ. BUT Cframe includes orientation so I dont see the need anyways.

Ad

Answer this question