Code I have so far:
script.Parent.ClickDetector.MouseClick:Connect(function() script.Parent.CFrame = CFrame.new(script.Parent.Position, script.Parent.Parent.FrontHood_I.Position) end)
Though a problem with the script is that FrontHood_I
's position makes script.Parent
(named FrontHood
) turns vertical instead of staying horizontal (FrontHood size XYZ values: 5.9, 0.5, 8.5). How do I keep FrontHood
or script.Parent
, horizontal instead of turning vertical? Also, FrontHood_I
is already vertical. It is an invisible part so FrontHood
or script.Parent
can move.
I simply want the hood to move from one position to another position and also have a rotation, like a car in real life would. For example, when a SUV's hood is opened, it starts flat and then opens to like a 60 degree angle or something. That's what I'm looking for.
Try this
script.Parent.ClickDetector.MouseClick:Connect(function() script.Parent.CFrame = script.Parent.Parent["FrontHood_I"].CFrame end)
(Make sure to position "FrontHood_I" to the exact position you want it to be when the hood is open)