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 » Scripting Helpers
Home Search
 

Re: Been studying Lua hard y'know.

Previous Thread :: Next Thread 
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
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 is not online. 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
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
16 Sep 2014 10:23 PM
I didn't want anything too complicated, so what you said it perfect.
Report Abuse
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
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
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
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 is not online. devTools
Joined: 06 Sep 2014
Total Posts: 7950
16 Sep 2014 10:40 PM
FindFirstChild. You forgot Capitol "f"
Report Abuse
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
16 Sep 2014 10:42 PM
It still didn't fix it :/ but thanks for pointing the typo out.
Report Abuse
blockoo is not online. 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
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
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
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
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
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
16 Sep 2014 10:57 PM
whoops forgot the 2 ends
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
16 Sep 2014 10:58 PM
and add hit inside the function untouch()
Report Abuse
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
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
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
16 Sep 2014 10:59 PM
scratch that it does stay there for good.
Report Abuse
cole7778 is not online. cole7778
Joined: 19 Nov 2009
Total Posts: 7827
16 Sep 2014 11:00 PM
it's "Bright green"
and
"Bright red"

d00d
Report Abuse
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
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
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
17 Sep 2014 06:10 PM
Ready for another hehehe.
Report Abuse
Nyxis is not online. 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 is not online. zakarq
Joined: 10 Oct 2010
Total Posts: 883
17 Sep 2014 06:14 PM
Make local lighting?
Report Abuse
eLunate is not online. 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
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
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 is not online. Nyxis
Joined: 15 Nov 2012
Total Posts: 3374
17 Sep 2014 06:40 PM
yes. clickdetector
Report Abuse
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
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 is not online. 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
UberGiantBuilder is not online. UberGiantBuilder
Joined: 08 Jul 2012
Total Posts: 1233
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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