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 With Disco Script

Previous Thread :: Next Thread 
Cukiryo is not online. Cukiryo
Joined: 21 Jun 2015
Total Posts: 11
05 May 2016 06:52 PM
I just started ROBLOX lua and I need help with a looping brickcolor disco script.


game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)
end)
if (msg == "Disco") then
wait(.2)
workspace.Player1.Head.BrickColor = BrickColor:random()
workspace.Player1.Torso.BrickColor = BrickColor:random()
workspace.Player1["Left Arm"].BrickColor = BrickColor:random()
workspace.Player1["Left Leg"].BrickColor = BrickColor:random()
workspace.Player1["Right Arm"].BrickColor = BrickColor:random()
workspace.Player1["Right Leg"].BrickColor = BrickColor:random()
end

----ends here--------------------------------------------------------

and how do you make a localplayer one that only you can say it?
Report Abuse
IlluminatiCat is not online. IlluminatiCat
Joined: 21 Feb 2009
Total Posts: 1216
05 May 2016 06:54 PM
You might want to take a look at coroutines for this one
Report Abuse
Salinas23 is not online. Salinas23
Joined: 28 Dec 2008
Total Posts: 37142
05 May 2016 06:54 PM
We can help you, but please specify how you want it to loop
Report Abuse
Cukiryo is not online. Cukiryo
Joined: 21 Jun 2015
Total Posts: 11
05 May 2016 06:55 PM
I want it to change color every 0.2 seconds
Report Abuse
Burglered is not online. Burglered
Joined: 14 Jul 2011
Total Posts: 962
05 May 2016 07:04 PM
A few problems here.
I know you might think "Ugh just fix it", but the point is to learn from your mistakes.

So first off, The 'if' statement should be inside the function. I noticed this error first. It should be
-----------------------------------------------------------
game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)

if (msg == "Disco") then
wait(.2)
workspace.Player1.Head.BrickColor = BrickColor:random()
workspace.Player1.Torso.BrickColor = BrickColor:random()
workspace.Player1["Left Arm"].BrickColor = BrickColor:random()
workspace.Player1["Left Leg"].BrickColor = BrickColor:random()
workspace.Player1["Right Arm"].BrickColor = BrickColor:random()
workspace.Player1["Right Leg"].BrickColor = BrickColor:random()
end
end)
-----------------------------------------------------------

Second error is that you never ended the p.Chatted function, you just declared it.
So you should add an end AFTER the if statement.
-----------------------------------------------------------
game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)

if (msg == "Disco") then
wait(.2)
workspace.Player1.Head.BrickColor = BrickColor:random()
workspace.Player1.Torso.BrickColor = BrickColor:random()
workspace.Player1["Left Arm"].BrickColor = BrickColor:random()
workspace.Player1["Left Leg"].BrickColor = BrickColor:random()
workspace.Player1["Right Arm"].BrickColor = BrickColor:random()
workspace.Player1["Right Leg"].BrickColor = BrickColor:random()
end
end) --right here!
end)
----------------------------------------------------------
NOTE**: This next part is optional but highly recommended!

And another thing is that when you do 'workspace.Player1.Head.BrickColor..., there is 3 things.
1. Create a variable for it. This makes it easier to manage and it doesn't take up so much space.
2. After you declared it as a variable, you should create another variable for the :FindFirstChild(variable) function to find the parts. Without this, If the part is nil(non-existent) then it will fail. With it, it will detect it and it wont give a bunch of errors.
3. After you created the FindFirstChild variable. Use an if statement to see if the part exists. For example: if(var == true) then BrickColorVariable = BrickColor.Random(); end

I'm sorry if this is too long, but I just wanted to help you out! There may be some things I missed, but I didn't want to take forever. You can use this advice in the future.

Thanks,
Burglered :)


Report Abuse
Cukiryo is not online. Cukiryo
Joined: 21 Jun 2015
Total Posts: 11
05 May 2016 07:09 PM
ok thanks will read all
Report Abuse
Cukiryo is not online. Cukiryo
Joined: 21 Jun 2015
Total Posts: 11
05 May 2016 07:13 PM
also how do you make it localplayer?
Report Abuse
Cukiryo is not online. Cukiryo
Joined: 21 Jun 2015
Total Posts: 11
05 May 2016 07:14 PM
oh it didn't loop the disco brickcolor.
Report Abuse
ItzLuigi12341 is not online. ItzLuigi12341
Joined: 13 Jun 2015
Total Posts: 43
05 May 2016 07:22 PM
Just add this to the brick you want to change color:

print("Hello world!")
while true do
script.Parent.Color = Color3.new(math.random(), math.random(), math.random())
wait(0.5) --Change that number to when you want it to change (Such as every .5 seconds)
end
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