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 |
|
|
|
| 05 May 2016 06:54 PM |
| You might want to take a look at coroutines for this one |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 21 Jun 2015 |
| Total Posts: 11 |
|
| |
|
Cukiryo
|
  |
| Joined: 21 Jun 2015 |
| Total Posts: 11 |
|
|
| 05 May 2016 07:13 PM |
| also how do you make it localplayer? |
|
|
| Report Abuse |
|
|
Cukiryo
|
  |
| Joined: 21 Jun 2015 |
| Total Posts: 11 |
|
|
| 05 May 2016 07:14 PM |
| oh it didn't loop the disco brickcolor. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|