Alpal425
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 214 |
|
|
| 22 May 2014 10:14 AM |
This is a script I made for an oven, and I got it done, but it's not working. :/ The 'door' is the oven door. Onclick, it will open. But if already open and clicked, it will close.
door = script.Parent
function onClicked() if door.Rotation = -0,0,0 then door.Rotation = 90,0,0 end if door.Rotation = 90,0,0 then door.Rotation = 0,0,0 end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
|
|
| Report Abuse |
|
|
|
| 22 May 2014 10:17 AM |
Rotation is a Vector3 value.
door.Rotation = 90,0,0
should be
door.Rotation = Vector3.new(90, 0, 0)
for example |
|
|
| Report Abuse |
|
|
Alpal425
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 214 |
|
|
| 22 May 2014 10:18 AM |
Oops, I meant this script. (I had an error in the other) door = script.Parent
function onClicked() if door.Rotation = -0,0,0 then door.Rotation = 90,0,0 else door.Rotation = -0,0,0 end if door.Rotation = 90,0,0 then door.Rotation = -0,0,0 else door.Rotation = 90,0,0 end end script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
|
| 22 May 2014 10:39 AM |
script.Parent.ClickDetector.MouseClick:connect(function() if door.Rotation.X==0 then door.Rotation=Vector3.new(90,0,0) elseif door.Rotation.X==90 then door.Rotation=Vector3.new(0,0,0) end) --didn't test this. (Made it in my browser.)
~masterCameron101, advanced Lua programmer, certified in Photoshop. Have I helped you? Don8~ |
|
|
| Report Abuse |
|
|
Alpal425
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 214 |
|
|
| 22 May 2014 10:58 AM |
| Doesn't work, and I'm trying everything to fix! |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 22 May 2014 11:02 AM |
clickDetector.MouseClick:connect(function() if door.Rotation = Vector3.new(0,0,0) then door.Rotation = Vector3.new(90,0,0) else door.Rotation = Vector3.new(0,0,0) end end)
Define clickDetector Define door |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 22 May 2014 11:03 AM |
clickDetector.MouseClick:connect(function() door.Rotation = Vector3.new(door.Rotation.X > 0 and 0 or 90,0,0) end)
^ maybe |
|
|
| Report Abuse |
|
|
Alpal425
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 214 |
|
|
| 22 May 2014 11:07 AM |
So, here is what I have.. door = script.Parent.Parent clickDectector = script.Parent
clickDetector.MouseClick:connect(function() if door.Rotation = Vector3.new(0,0,0) then door.Rotation = Vector3.new(90,0,0) else door.Rotation = Vector3.new(0,0,0) end end)
And this is the error it says in the script..
Line 6.. 'then' expected near '=' |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
|
| 22 May 2014 11:08 AM |
did I seriously forget a =?!
DEFINE THE THINGS.
clickDetector.MouseClick:connect(function() if door.Rotation == Vector3.new(0,0,0) then door.Rotation = Vector3.new(90,0,0) else door.Rotation = Vector3.new(0,0,0) end end) |
|
|
| Report Abuse |
|
|
Alpal425
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 214 |
|
|
| 22 May 2014 11:17 AM |
| THE SCRIPT WORKS! :D Now all I have to do is find the correct positioning, I guess I got the numbers wrong... the oven door is going through the burners. o-o LOL |
|
|
| Report Abuse |
|
|
Alpal425
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 214 |
|
|
| 22 May 2014 11:19 AM |
How would I make it so it also sets it to this position? x3
2.48, 2.99, 31.3
Sorry for the trouble... o-o I just never worked with positioning and Vector3 values and stuff. |
|
|
| Report Abuse |
|
|
Alpal425
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 214 |
|
|
| 22 May 2014 11:23 AM |
Pose 1 Rotation 90,0,0 Position 2.48, 2.79, 31.3
Pose 2 Position 2.48, 4.19, 30.1 Rotation 0,0,0 |
|
|
| Report Abuse |
|
|
|
| 22 May 2014 12:35 PM |
This probably won't work but you need t use CFrame.Angles not rotation maybe some one can fix this if it doesn't work.
local function MoveModel(Model,NewCFrame) local Center=Model.Center Center.CFrame=NewCFrame door = script.Parent
function onClicked() for i = 1,10 do MoveModel(door,door.Center.CFrame*CFrame.Angles(0,0,0.49)) wait(0.070) end script.Parent.ClickDetector.MouseClick:connect(onClicked) end end
|
|
|
| Report Abuse |
|
|