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 » Game Design
Home Search
 

Re: What is wrong with this code?

Previous Thread :: Next Thread 
JayLikesROBLOX is not online. JayLikesROBLOX
Joined: 29 Sep 2013
Total Posts: 309
22 Aug 2015 03:44 PM
The code is supposed to make it have a randomized outcome every time you touch the block renamed mem. It works, however you can only touch the block one time, and then it just wont do anything again. This is the code

local stop=false
script.Parent.Touched:connect(function (hit)
if not stop then
stop=true
local val=math.random(1,3)
if val==1 then
game.Workspace.mem1.CanCollide=true
game.Workspace.mem2.CanCollide=false
game.Workspace.mem3.CanCollide=false
game.Workspace.mem2.Transparency=0.25
game.Workspace.mem3.Transparency=0.25
wait(0.05)
game.Workspace.mem2.Transparency=0
game.Workspace.mem3.Transparency=0
elseif val==2 then
game.Workspace.mem1.CanCollide=false
game.Workspace.mem2.CanCollide=true
game.Workspace.mem3.CanCollide=false
game.Workspace.mem1.Transparency=0.25
game.Workspace.mem3.Transparency=0.25
wait(0.05)
game.Workspace.mem1.Transparency=0
game.Workspace.mem3.Transparency=0
else
game.Workspace.mem1.CanCollide=false
game.Workspace.mem2.CanCollide=false
game.Workspace.mem3.CanCollide=true
game.workspace.mem1.Transparency=0.25
game.Workspace.mem2.Transparency=0.25
wait(0.05)
game.Workspace.mem1.Transparency=0
game.Workspace.mem2.Transparency=0
end
end
end)
Report Abuse
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
22 Aug 2015 03:55 PM
you set stop to true, then never set it back to false.
Report Abuse
lightpower26 is not online. lightpower26
Joined: 26 Apr 2012
Total Posts: 1046
22 Aug 2015 04:02 PM
You never really set stop to false. You left it at true. Just add at the end stop = false
Report Abuse
JayLikesROBLOX is not online. JayLikesROBLOX
Joined: 29 Sep 2013
Total Posts: 309
22 Aug 2015 04:28 PM
i already figured out the error a short time after posting this, but thanks anyway.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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