Hibobb
|
  |
| Joined: 18 Apr 2010 |
| Total Posts: 2146 |
|
|
| 16 Jun 2013 04:42 PM |
output: 17:42:36.812 - Players.Player1.PlayerGui.ScreenGui.TextButton.LocalScript:10: 'then' expected near '='
script: function lock() game.Players.LocalPlayer.CameraMode = "LockFirstPerson" end
function unlock() game.Players.LocalPlayer.CameraMode = "Classic" end
function clicked() if game.Players.LocalPlayer.CameraMode = "Classic" then lock() elseif game.Players.LocalPlayer.CameraMode = "LockFirstPerson" then unlock() end end
script.Parent.MouseButton1Down:connect(clicked) |
|
|
| Report Abuse |
|
|
shred1894
|
  |
| Joined: 30 Aug 2009 |
| Total Posts: 6515 |
|
|
| 16 Jun 2013 04:44 PM |
wait(.1) function lock() game.Players.LocalPlayer.CameraMode = "LockFirstPerson" end
function unlock() game.Players.LocalPlayer.CameraMode = "Classic" end
function clicked() if game.Players.LocalPlayer.CameraMode == "Classic" then lock() elseif game.Players.LocalPlayer.CameraMode == "LockFirstPerson" then unlock() end end
script.Parent.MouseButton1Down:connect(clicked)
S-1894>(Supreme_Commander_of_Advanced_Zero) |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2013 04:50 PM |
You have to use a comparison in If statements. When you use a single =, Lua thinks you're trying to define it, but when you use ==, Lua replaces the two compared with a true or false depending on whether it really is true or false.
potato = potato
If potato == carrot then print("WHOA") end |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2013 04:54 PM |
"If" statements that tell wether something is true or false require double =. function lock() game.Players.LocalPlayer.CameraMode = "LockFirstPerson" end
function unlock() game.Players.LocalPlayer.CameraMode = "Classic" end
function clicked() if game.Players.LocalPlayer.CameraMode == "Classic" then lock() elseif game.Players.LocalPlayer.CameraMode == "LockFirstPerson" then unlock() end end
script.Parent.MouseButton1Down:connect(clicked) |
|
|
| Report Abuse |
|
|