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 » Scripters
Home Search
 

Re: Help on Script

Previous Thread :: Next Thread 
Dribben is not online. Dribben
Joined: 11 Feb 2012
Total Posts: 25
17 Feb 2016 06:48 PM
Hello! I am quite a noob to the scripting community, but I'm trying very hard to learn! I have attempted to create a script that makes my baseplate go from red to blue very fast. This is what I have:

local myBasePlate = game.Workspace.Baseplate

local function Red()
myBasePlate.BrickColor = BrickColor.Red()
print("RED")--This is to see that it is switching.
end

local function Blue()
myBasePlate.BrickColor = BrickColor.Blue()
print("BLUE")--This is to see that it is switching.
end

if Red() then
Blue()
else
Red()

end
--IT DOESN'T WORK!! D: D: D: Please help!

Report Abuse
goro7 is not online. goro7
Joined: 01 Jul 2009
Total Posts: 735
17 Feb 2016 06:50 PM
Like this?

local myBasePlate = game.Workspace.Baseplate

local function Red()
myBasePlate.BrickColor = BrickColor.Red()
print("RED")--This is to see that it is switching.
end

local function Blue()
myBasePlate.BrickColor = BrickColor.Blue()
print("BLUE")--This is to see that it is switching.
end

while wait() do
if myBasePlate.BrickColor == BrickColor.Red() then
Blue()
else
Red()
end
Report Abuse
Dribben is not online. Dribben
Joined: 11 Feb 2012
Total Posts: 25
17 Feb 2016 07:24 PM
Didn't work. You never finished the "while wait() do" string.
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
17 Feb 2016 07:26 PM
Here's a neat method that uses nested function calls to escape looping.

local part = workspace.Baseplate

function blue()
part.BrickColor=BrickColor.Blue()
wait()
red()
end

function red()
part.BrickColor=BrickColor.Red()
wait()
blue()
end

blue()

That might work
Report Abuse
Dribben is not online. Dribben
Joined: 11 Feb 2012
Total Posts: 25
17 Feb 2016 07:34 PM
Wow! I just did that, trying to figure it out! Here it is now:

local myBasePlate = game.Workspace.Baseplate

local function Red()
myBasePlate.BrickColor = BrickColor.Red()
print("RED")--This is to see that it is switching.
end

local function Gray()
myBasePlate.BrickColor = BrickColor.DarkGray()
print("GRAY")--This is to see that it is switching.
end


if myBasePlate.BrickColor == BrickColor.Red() then
wait(2)
Gray()
end

if myBasePlate.BrickColor == BrickColor.DarkGray() then
wait(2)
Red()
end


This works quite well, since the baseplate is initially Dark Gray. The only thing I see is that after it switches to Red, it doesn't switch back to Gray again. I don't know why, though.





Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
17 Feb 2016 07:36 PM
local myBasePlate = game.Workspace.Baseplate

local function Red()
myBasePlate.BrickColor = BrickColor.Red()
print("RED")--This is to see that it is switching.
end

local function Gray()
myBasePlate.BrickColor = BrickColor.DarkGray()
print("GRAY")--This is to see that it is switching.
end

while true do
if myBasePlate.BrickColor == BrickColor.Red() then
wait(2)
Gray()
end

if myBasePlate.BrickColor == BrickColor.DarkGray() then
wait(2)
Red()
end
end
Report Abuse
Dribben is not online. Dribben
Joined: 11 Feb 2012
Total Posts: 25
17 Feb 2016 07:47 PM
Ah, that worked! Magnificent! Thank you! I haven't learned the "while true do" function yet. I'll keep researching the functions to make more scripts without asking for help. Thank you!
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
17 Feb 2016 07:49 PM
Your welcome.
Report Abuse
Dribben is not online. Dribben
Joined: 11 Feb 2012
Total Posts: 25
18 Feb 2016 08:45 PM
For some odd reason this script has started to crash my Roblox studio. Do you know why?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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