generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: what am i missing?

Previous Thread :: Next Thread 
Hibobb is not online. 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 is not online. 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
DaneelOlivaw is not online. DaneelOlivaw
Joined: 14 Apr 2012
Total Posts: 661
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
icegroudon is not online. icegroudon
Joined: 08 Oct 2011
Total Posts: 2924
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image