|
| 10 Jun 2016 03:03 AM |
How do I make a function that will fire when someone untouched a part?
|
|
|
| Report Abuse |
|
|
soved
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 216 |
|
|
| 10 Jun 2016 03:11 AM |
local Part = script.Parent
Part.TouchEnded:connect(function() -- Do stuff. end) |
|
|
| Report Abuse |
|
|
soved
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 216 |
|
|
| 10 Jun 2016 03:12 AM |
The event will Fire a few times, so just add a Debounce.
Hope this helps. |
|
|
| Report Abuse |
|
|
ElectroTM
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 1135 |
|
|
| 10 Jun 2016 03:15 AM |
local Part = script.Parent local deb=false Part.TouchEnded:connect(function() if not deb then -- Do stuff. deb=true wait(.2)--or something deb=false end end)
|
|
|
| Report Abuse |
|
|
Autreus
|
  |
| Joined: 27 Feb 2015 |
| Total Posts: 290 |
|
|
| 10 Jun 2016 04:13 AM |
I think I know what you mean..
Insert a ClickDetector and a Script inside,
script.Parent.ClickDetector.MouseClick:connect(function() script.Parent. end)
This will be what you will be starting with. Between the end) and script.Parent you will want to type of thing you want to happend. If you want it to be clickable (toggle between true, false) :
script.Parent.ClickDetector.MouseClick:connect(function() if script.Parent.(whatyouwant) == 0 then script.Parent.(whatyouwant) else script.Parent.(whatyouwant) end end) |
|
|
| Report Abuse |
|
|
Lem0nzzx
|
  |
| Joined: 08 Feb 2016 |
| Total Posts: 1604 |
|
|
| 10 Jun 2016 05:47 AM |
| if (plr.Torso.Position - pad.Position).magnitude < 3 then print'stepped off' end |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 10 Jun 2016 06:06 AM |
| greater than, not less than |
|
|
| Report Abuse |
|
|
jbjgang2
|
  |
| Joined: 07 Feb 2010 |
| Total Posts: 8948 |
|
|
| 10 Jun 2016 07:11 AM |
@lem0nzzx
that would be pretty innefficent seeing as it would fire only when your 3 studs away from the parts origin and not touching it
a correct way of doing that would be
(plr.Torso.Position - pad.Position).magnitude > pad.Size.X/2
but this would only work if the part was a perfect cube
|
|
|
| Report Abuse |
|
|