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
 

Workspace.Part.Script:2: 'then' expected near '='

Previous Thread :: Next Thread 
Staplers10 is not online. Staplers10
Joined: 09 Sep 2010
Total Posts: 409
28 Jul 2011 09:35 AM
Here is the script. I will only post the error.

function onTouch()
if game.Workspace.Frame.Transparency = 1 then
--Stuff goes here.
else
if game.Workspace.Frame.Transparency = 0 then
--Other stuff goes here.
end
end
end

script.Parent.Touched:connect(onTouch)

Here is the output:
Workspace.Part,Script:2:
'then expected
near '='

This happens everytime I use an if statement. I don't understand what the output is telling me since I already have then on the script. Can anyone help me?
Report Abuse
61352151511 is not online. 61352151511
Joined: 30 Nov 2009
Total Posts: 8094
28 Jul 2011 09:38 AM
if game.Workspace.Frame.Transparency = 1 then

when checking a value user double ='s

if game.Workspace.Frame.Transparency == 1 then

‹•º`¨´º•¸
~ Mitch ~
¸•º`¨´º•›
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
28 Jul 2011 09:40 AM
When making a statement,
You want to check if something is equal to,
Not equals __.
Also you can use "elseif" insead of "else if",
using mine you need no extra end.
And I added a debounce.

enabled = true
function onTouch()
if not enabled then
return end
enabled = false
if game.Workspace.Frame.Transparency == 1 then
--Stuff goes here.
elseif game.Workspace.Frame.Transparency == 0 then
--Other stuff goes here.
end
enabled = true
end
script.Parent.Touched:connect(onTouch)

Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
28 Jul 2011 09:41 AM
Mitch beat me :L
Report Abuse
61352151511 is not online. 61352151511
Joined: 30 Nov 2009
Total Posts: 8094
28 Jul 2011 09:41 AM
Of course I beat you, you typed like 2 paragraphs

‹•º`¨´º•¸
~ Mitch ~
¸•º`¨´º•›
Report Abuse
Staplers10 is not online. Staplers10
Joined: 09 Sep 2010
Total Posts: 409
28 Jul 2011 09:42 AM
Thanks. I don't need a debounce, but thanks for telling me the elseif and == thing.
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
28 Jul 2011 09:48 AM
Actually, you will find when using touch events you need debounces a lot of the time. I personally do enabled, not debounce, but they do the same thing. If you have print()'s in your script, they will print multiple times if you dont have a debounce.
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