of     1   

UnforeseenVice
#223690420Tuesday, August 15, 2017 4:15 AM GMT

Hello, I am trying to make a simple light switch and I would like the brick to rotate when clicked. The current script is: local switch = script.Parent function onClicked() switch.Orientation = Vector3.new(5,0,0) wait(.01) switch.Position = Vector3.new(-3.05, 5.9, -78.95) end script.Parent.ClickDetector.MouseClick:connect(onClicked) But for whatever reason, the switch is moved from its postion. Ive tried with and without the "switch.Position = Vector3.new(-3.05, 5.9, -78.95)" line. Can someone tell me what im doing wrong.
UnforeseenVice
#223690716Tuesday, August 15, 2017 4:24 AM GMT

help me pls ;(
WeeWeeInspector
#223690995Tuesday, August 15, 2017 4:33 AM GMT

You should use CFrame instead of changing the orientation and position, not only that use wait() instead of putting in .01 since wait() is the lowest duration you can generally go. Also, post this in the scripters forums next time.
WeeWeeInspector
#223691333Tuesday, August 15, 2017 4:43 AM GMT

I just looked at some of your creations and I think you're just being sarcastic about this lol.
UnforeseenVice
#223691470Tuesday, August 15, 2017 4:47 AM GMT

I just build, i dont script. I legit have no clue what im doing wrong, ive never learned cframe. I just know the very basics of scripting, hardly that.
helloburp
#223691591Tuesday, August 15, 2017 4:50 AM GMT

When changing an object's position in the world, directly setting it's position will shift it above anything it collides with. If you change it's CFrame instead, it will retain a raw position without being nudged, unless it's unanchored of course switch.CFrame = CFrame.new(-3.05, 5.9, -78.95) I would also like to suggest that you change it's CFrame on a relative basis so that if you want to move the switch, you don't have to edit the script. Example: switch.CFrame = switch.CFrame + Vector3.new(0,1,0) --Will shift the switch up one unit
UnforeseenVice
#223692325Tuesday, August 15, 2017 5:12 AM GMT

@Helloburp Thank you, that helped a lot. The switch is now in the correct position but now a new problem has come up. The orientation no longer goes into the position i need it. Any fix for that?
TinyGravity
#223694505Tuesday, August 15, 2017 6:44 AM GMT

Use CFrame.Angles()

    of     1