|
| 16 Sep 2014 10:20 PM |
| So its been about a week-ish since I starting playing again and I did some learning of Lua. I would like something simple to try to make, but not too simple. So tell me to make a script for something and I will attempt to make it. Thanks in advance. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 16 Sep 2014 10:22 PM |
| How complicated? How about a brick that stays green while you're touching it, and turns red while you're not touching it? |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2014 10:23 PM |
| I didn't want anything too complicated, so what you said it perfect. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2014 10:37 PM |
| I attempted it and I see nothing wrong and neither does the output, but it doesn't work. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2014 10:38 PM |
I forgot the script oops
function onTouch(hit) if hit.Parent:findFirstChild("Humanoid") then game.Workspace.BasePlate.BrickColor = BrickColor.new("Bright Green") else game.Workspace.BasePlate.BrickColor = BrickColor.new("Bright Red") end end script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
devTools
|
  |
| Joined: 06 Sep 2014 |
| Total Posts: 7950 |
|
|
| 16 Sep 2014 10:40 PM |
| FindFirstChild. You forgot Capitol "f" |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2014 10:42 PM |
| It still didn't fix it :/ but thanks for pointing the typo out. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 16 Sep 2014 10:46 PM |
| It's just a dumb little error with the brickcolor strings. The second word in every brickcolor should be lowercase. Also, what you have there won't exactly accomplish what you want. Look into the TouchEnded event. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2014 10:49 PM |
| You're right, it turns green but when I'm off it it doesn't turn red. |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2014 10:56 PM |
function onTouch(hit) if hit.Parent:findFirstChild("Humanoid") ~= nil then game.Workspace.BasePlate.BrickColor = BrickColor.new("Bright Green") end end script.Parent.Touched:connect(onTouch)
function untouch() if hit.Parent:findFirstChild("Humanoid") ~= nil then game.Workspace.BasePlate.BrickColor = BrickColor.new("Bright Red")
script.Parent.TouchEnded:connect(untouch)
|
|
|
| Report Abuse |
|
|
| |
|
|
| 16 Sep 2014 10:58 PM |
| and add hit inside the function untouch() |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2014 10:58 PM |
In a way you could say I did it, because it does work like that, I wanted it to more stay red when I stopped touching it, but instead it just flashes red for a second. Heres the "final" script.
function onTouch(hit) if hit.Parent:FindFirstChild("Humanoid") then game.Workspace.Part.BrickColor = BrickColor.new("Bright green") end end script.Parent.Touched:connect(onTouch) function TouchEnded() if Humanoid == nil then game.Workspace.Part.BrickColor = BrickColor.new("Bright red") end end script.Parent.TouchEnded:connect(TouchEnded) |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2014 10:59 PM |
| scratch that it does stay there for good. |
|
|
| Report Abuse |
|
|
cole7778
|
  |
| Joined: 19 Nov 2009 |
| Total Posts: 7827 |
|
|
| 16 Sep 2014 11:00 PM |
it's "Bright green" and "Bright red"
d00d |
|
|
| Report Abuse |
|
|
|
| 16 Sep 2014 11:02 PM |
| You guys did it differently than i did but I made mine work. Well I'll probably bump this or something tomorrow so I can try something else. |
|
|
| Report Abuse |
|
|
| |
|
Nyxis
|
  |
| Joined: 15 Nov 2012 |
| Total Posts: 3374 |
|
|
| 17 Sep 2014 06:14 PM |
| can you make a button door that cframes open & closed with proper debounce |
|
|
| Report Abuse |
|
|
zakarq
|
  |
| Joined: 10 Oct 2010 |
| Total Posts: 883 |
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 17 Sep 2014 06:20 PM |
| Move part1 to a random instance of part2 (there are multiple) every 10 seconds. Had to answer this one for somebody else, so it's not too difficult if your brain is in gear for logic. |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2014 06:27 PM |
| Nyxis I assume you mean a button which is activated by clicking not like being stepped on or whatever. |
|
|
| Report Abuse |
|
|
Nyxis
|
  |
| Joined: 15 Nov 2012 |
| Total Posts: 3374 |
|
| |
|
|
| 17 Sep 2014 06:44 PM |
| The two problems I'm having is the connect line and finding out not how but why I would need debounce and how to put it in a script like this. |
|
|
| Report Abuse |
|
|
Nyxis
|
  |
| Joined: 15 Nov 2012 |
| Total Posts: 3374 |
|
|
| 17 Sep 2014 06:45 PM |
debounce so you can't spam the button, and so it knows whether or not to open/close it.
oh yeah, and make it only use one button :) |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2014 07:16 PM |
It took a while because I had to actually learn to do debounce, but for my first try I modeled it after the example the wiki gave me. But it works well enough I guess.
--CFrame pos 1 = -27,6,31 CFrame pos 2 = -18.5, 9, 31 local buttonPressed = false
Workspace.Button.ClickDetector.MouseClick:connect(function(Click) if not buttonPressed then buttonPressed = true game.Workspace.Door.CFrame = CFrame.new(-18.5, 9, 31) wait (4) game.Workspace.Door.CFrame = CFrame.new(-27, 6, 31) buttonPressed = false end end) |
|
|
| Report Abuse |
|
|