|
| 19 Jul 2013 09:24 PM |
r = script.Parent.R y = script.Parent.Y g = script.Parent.G
function onTouched() if r.BrickColor = ("Bright red") then script.Parent.Alarm.Volume = 3 script.Parent.Alarm:play() elseif return nil end end
script.Parent.RTrigger.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
|
| 19 Jul 2013 09:25 PM |
| BrickColor.new("Bright red") |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2013 09:26 PM |
Oh, and just else. Not elseif.
--[[FLOOOOOOODCHEEEEEECK!!!]]-- |
|
|
| Report Abuse |
|
|
kinglime
|
  |
| Joined: 27 Jun 2008 |
| Total Posts: 2751 |
|
|
| 19 Jul 2013 09:27 PM |
So
r = script.Parent.R y = script.Parent.Y g = script.Parent.G
function onTouched() if r.BrickColor = BrickColor.new("Bright red") then script.Parent.Alarm.Volume = 3 script.Parent.Alarm:play() else return nil end end
script.Parent.RTrigger.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2013 09:29 PM |
| Would I not need something like if r.BrickColor bla bla = true? |
|
|
| Report Abuse |
|
|
tummey2
|
  |
| Joined: 04 Feb 2009 |
| Total Posts: 1802 |
|
|
| 19 Jul 2013 09:29 PM |
Two equals in the if statement
if r.BrickColor == BrickColor.new("Bright red") then
|
|
|
| Report Abuse |
|
|
|
| 19 Jul 2013 09:31 PM |
| Alright so script works but the problem is the alarm sounds more than ounce like it tries to overwrite the first sound. |
|
|
| Report Abuse |
|
|
tummey2
|
  |
| Joined: 04 Feb 2009 |
| Total Posts: 1802 |
|
|
| 19 Jul 2013 09:34 PM |
Add debounce and check if the touch is coming from a player.
r = script.Parent.R y = script.Parent.Y g = script.Parent.G debounce = false
function onTouched(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if r.BrickColor = BrickColor.new("Bright red") and hum ~= nil then script.Parent.Alarm.Volume = 3 script.Parent.Alarm:play() debounce = true wait(1) -- Time between being able to use it again debounce = false else return nil end end
script.Parent.RTrigger.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
kinglime
|
  |
| Joined: 27 Jun 2008 |
| Total Posts: 2751 |
|
|
| 19 Jul 2013 09:34 PM |
r = script.Parent.R y = script.Parent.Y g = script.Parent.G bounce = false
function onTouched() if r.BrickColor == BrickColor.new("Bright red") then bounce = true script.Parent.Alarm.Volume = 3 script.Parent.Alarm:Play() script.Parent.Alarm.Looped = false wait(1) bounce = false else return nil end end
script.Parent.RTrigger.Touched:connect(onTouched)
I guess that would work. |
|
|
| Report Abuse |
|
|
kinglime
|
  |
| Joined: 27 Jun 2008 |
| Total Posts: 2751 |
|
|
| 19 Jul 2013 09:35 PM |
Lol he beat me to it xD His prob works better anyways. |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2013 09:36 PM |
| Explain what bounce=false does please |
|
|
| Report Abuse |
|
|
kinglime
|
  |
| Joined: 27 Jun 2008 |
| Total Posts: 2751 |
|
|
| 19 Jul 2013 09:38 PM |
| http://wiki.roblox.com/index.php/Debounce |
|
|
| Report Abuse |
|
|
tummey2
|
  |
| Joined: 04 Feb 2009 |
| Total Posts: 1802 |
|
|
| 19 Jul 2013 09:39 PM |
It's a boolean, there's no actual bouncing. It's basically saying if the player touches and the bool is false then run the important stuff in the function if not, return nil.
Once the main jist of the function is running make the bool = true so that it can't be activated until it's false again. (Hence the end of the function) |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2013 09:43 PM |
so could I possibly go
r = script.Parent.R y = script.Parent.Y g = script.Parent.G a = script.Parent.Alarm
function onTouched() if r.BrickColor == BrickColor.new("Bright red") then a.Volume = 1 a:play() a.Loop = false debounce = true wait(1) else return nil end end
script.Parent.RTrigger.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
tummey2
|
  |
| Joined: 04 Feb 2009 |
| Total Posts: 1802 |
|
|
| 19 Jul 2013 09:45 PM |
r = script.Parent.R y = script.Parent.Y g = script.Parent.G debounce = false
function onTouched(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if r.BrickColor == BrickColor.new("Bright red") and hum ~= nil and debounce == false then -- Overlap, this should be at the end of the line above script.Parent.Alarm.Volume = 3 script.Parent.Alarm:play() debounce = true wait(1) -- Time between being able to use it again debounce = false else return nil end end
script.Parent.RTrigger.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
tummey2
|
  |
| Joined: 04 Feb 2009 |
| Total Posts: 1802 |
|
|
| 19 Jul 2013 09:45 PM |
| Woops, it didn't end up overlapping, my bad! |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2013 09:46 PM |
| This is confusing in text, is there a tutorial? |
|
|
| Report Abuse |
|
|
tummey2
|
  |
| Joined: 04 Feb 2009 |
| Total Posts: 1802 |
|
|
| 19 Jul 2013 09:47 PM |
| KingLime posted a wiki link. |
|
|
| Report Abuse |
|
|
kinglime
|
  |
| Joined: 27 Jun 2008 |
| Total Posts: 2751 |
|
|
| 19 Jul 2013 09:47 PM |
r = script.Parent.R y = script.Parent.Y g = script.Parent.G a = script.Parent.Alarm bounce = false
function onTouched() if r.BrickColor == BrickColor.new("Bright red") then bounce = true a.Volume = 1 a:play() a.Looped = false wait(1) bounce = false else return nil end end
script.Parent.RTrigger.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2013 09:49 PM |
Maybe if I explain the situation a little better.
Notice I have another working traffic light script...
You basically run a red light and a brick triggers the sound of a police siren. Also if you can help me I want to make it add a hint that says bla bla I can edit it later. |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2013 09:50 PM |
Now when I try and go through the second time it will not work. Here is what I have.
r = script.Parent.R y = script.Parent.Y g = script.Parent.G a = script.Parent.Alarm debounce = false
function onTouched() if r.BrickColor == BrickColor.new("Bright red") then a.Volume = 1 a:play() a.Loop = false debounce = true wait(1) debounce = false else return nil end end
script.Parent.RTrigger.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
kinglime
|
  |
| Joined: 27 Jun 2008 |
| Total Posts: 2751 |
|
|
| 19 Jul 2013 09:53 PM |
There is a couple ways you could do that, but for you the most simple would be to use 2 parts.
One under the red light, have a while true do loop to check if the light is red if it is and the user runs(touches the part under the light) it then something will happen. |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2013 09:59 PM |
r = script.Parent.R y = script.Parent.Y g = script.Parent.G a = script.Parent.Alarm debounce = false
function onTouched() if r.BrickColor == BrickColor.new("Bright red") then a.Volume = 1 a:play() a.Loop = false debounce = true wait(1) debounce = false a:stop() else return nil end end
script.Parent.RTrigger.Touched:connect(onTouched)
|
|
|
| Report Abuse |
|
|
tummey2
|
  |
| Joined: 04 Feb 2009 |
| Total Posts: 1802 |
|
|
| 19 Jul 2013 10:17 PM |
r = script.Parent.R y = script.Parent.Y g = script.Parent.G a = script.Parent.Alarm debounce = false
function onTouched() if r.BrickColor == BrickColor.new("Bright red") and debounce == false then a.Volume = 1 a:play() a.Loop = false debounce = true wait(1) debounce = false a:stop() end end
script.Parent.RTrigger.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|