|
| 31 Dec 2012 10:18 PM |
I am on LuaLearners' website. I am on the intermadiate tutorial and I have a task: Make a script that, when touched: 1.) Changes color(red) 2.) Moves Random 3.) Kills Player 4.) And gives the message "Someone touched this brick"
function onTouched(part) h = game.Workspace.Part local p = Instance.new("Message",game.Workspace) local b = part.Parent:findFirstChild("Humanoid") if b ~= nil then b.Health = 0 h.Color = Color3.new(225, 0, 0) h.Position = Vector3.new(math.random(0.5), math.random(0,5), math.random(0,5)) p.Text = "This is a message" end end script.Parent.Touched:connect(onTouched)
Is my string set up wrong? Do I have something in the wrong place? Please reply with, not just the correct way but, with an explanation please. |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2012 10:31 PM |
| I really need help. I am just learning, |
|
|
| Report Abuse |
|
|
crouton04
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 4459 |
|
|
| 31 Dec 2012 10:35 PM |
script.Parent.Touched:connect(function (hit) script.Parent.BrickColor = BrickColor.new("Bright red") script.Parent.Position = Vector3.new(math.random(512), math.random(512), math.random(512))
msg = Instance.new("Message",Workspace) msg.Text = "This brick was touched!" wait(4) msg:Remove()
end) |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2012 10:39 PM |
| You can't change the color of a part with Color3, you need part.BrickColor=BrickColor.new(colorname). |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2012 10:53 PM |
| Using Color3.new changed the color. I learned it on LuaLearners site. |
|
|
| Report Abuse |
|
|
noah
|
  |
| Joined: 11 Sep 2006 |
| Total Posts: 18977 |
|
|
| 31 Dec 2012 10:55 PM |
@watch all the properties of a part is in the middle column of this page: http://wiki.roblox.com/index.php/Part
do u see the property called "Color"? nop |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2013 08:58 AM |
http://www.lualearners.org/tutorial?tut=27
Do you see it here YES. Stop trying to prove me wrong when I know what I saw. |
|
|
| Report Abuse |
|
|
Z007
|
  |
| Joined: 14 Sep 2010 |
| Total Posts: 11729 |
|
|
| 01 Jan 2013 09:03 AM |
After I'm done testing my script I'll go and check to see if Color3 works. I don't think it does though. The roblox wiki is a better place to learn scriptin' though. |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 01 Jan 2013 09:06 AM |
Guys stop messing his mind! I've always used Color3 on parts and even if I'd sound arrogant, I'd say I know Lua way better than you.
Though @op, you need to use number between 0 and 1, since Color3 doesn't accept 0-225. For you it worked, because it automatically rounds 225 down to 1.
In sec I'll look for your problem, so wait... |
|
|
| Report Abuse |
|
|
Z007
|
  |
| Joined: 14 Sep 2010 |
| Total Posts: 11729 |
|
|
| 01 Jan 2013 09:08 AM |
| Color = Color3.new(blah, blah, blah) is indeed possible; it is easier to use a BrickColor.new("Blahblahblah") script though. |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 01 Jan 2013 09:10 AM |
function onTouched(part) h = game.Workspace.Part local p = Instance.new("Message",game.Workspace) local b = part.Parent:findFirstChild("Humanoid") if b then --You don't need ~= nil here, since "If b is true then continue" --b.Health = 0 in my opinion, breaking joints will be more effective. b.Parent:BreakJoints() h.Color = Color3.new(1, 0, 0)--As I said, color3 ranges from 0 to 1 h.Position = Vector3.new(math.random(0,5), math.random(0,5), math.random(0,5))--You had 0.5 instead of 0,5 p.Text = "This is a message" end end script.Parent.Touched:connect(onTouched)
I didn't see anything to critical in this script, but Idk try it. |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2013 10:02 AM |
I found the problem. I DID IT:D. I know thisis a noob script but I'm learning.
Problem script:
function onTouched(h) --funtction set to "h" local h = part.Parent:findFirstChild("Humanoid") --I changed "part""to "h" and changed "local h" to "local x" to keep the script from confusing the function with this line. if h ~= nil then --changed "h" to "x" h.Health = 0 --changed to "x" b = game.Workspace.Part b.Color = Color3.new(225,0,0) b.Position = Vector3.new(math.random(1,5), math.random(1,5), math.random(1,5)) local p = Instance.new("Message",game.Workspace) p.Text = "Somebody Touched The Part!" end end
script.Parent.Touched:connect(onTouched)
function onTouched(h) --Kept same local x = h.Parent:findFirstChild("Humanoid") --changed to "x" if x ~= nil then --changed to "x' x.Health = 0 --changed to "x' b = game.Workspace.Part b.Color = Color3.new(225,0,0) b.Position = Vector3.new(math.random(1,5), math.random(1,5), math.random(1,5)) local p = Instance.new("Message",game.Workspace) p.Text = "Somebody Touched The Part!" end end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
| |
|
doneyes
|
  |
| Joined: 21 Mar 2008 |
| Total Posts: 3466 |
|
|
| 01 Jan 2013 12:13 PM |
| Color3 is used for colors like smoke and fire. Not parts. That website is wrong if that's what you saw. |
|
|
| Report Abuse |
|
|
crouton04
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 4459 |
|
| |
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 01 Jan 2013 03:22 PM |
| @doneyes. Umt stop messing his head! I've used Color3 on everything, since I like it better, because I don't have to check for name of color or it's index. |
|
|
| Report Abuse |
|
|
jelly134
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 1137 |
|
|
| 01 Jan 2013 03:33 PM |
@ the color thing. It is a member of Part, but a deprecated one. It works, but rounds the Color3 to the nearest BrickColor that it can find.
part.Color = BrickColor.new("Really red").Color
part.BrickColor = BrickColor.new("Really red")
part.BrickColor = BrickColor.new(Color3.new(1,0,0))
--These all do the same thing. |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 01 Jan 2013 03:37 PM |
| Well, it always has rounded it down to BrickColor, but still, it's easier to do that, than checking the name of color. |
|
|
| Report Abuse |
|
|
tears3106
|
  |
| Joined: 15 Jul 2009 |
| Total Posts: 1396 |
|
|
| 01 Jan 2013 04:13 PM |
function onTouched(hit) h = script.Parent local g = game.Players:GetPlayerFromCharacter(hit.Parent) local p = Instance.new("Message", g.PlayerGui) local b = hit.Parent:findFirstChild("Humanoid") if b ~= nil then b.Health = 0 h.Color = Color3.new(225, 0, 0) h.Position = Vector3.new(math.random(0,5), math.random(0,5), math.random(0,5)) p.Text = "This is a message" end end script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
crouton04
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 4459 |
|
|
| 01 Jan 2013 04:43 PM |
| h.Color = Color3.new(225/255, 0/255, 0/255) |
|
|
| Report Abuse |
|
|
|
| 01 Jan 2013 08:48 PM |
| Clor3 ranges from (0,225) in colors Red Blue and Green. You can make am mixture to change colors. And they do work on bricks. |
|
|
| Report Abuse |
|
|