|
| 08 Oct 2014 04:41 PM |
sp = script.Parent q = "p = " p = "q"
while true do
debounce = true
function onTouched() debounce = false m = Instance.new("Message", workspace) m.Text = q .. p debounce = true wait(5) m:Remove() end wait() end
sp.Touched:connect(onTouched)
Whenever I put the function call into the while loop it works, but if I take it out it doesn't. :P |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 08 Oct 2014 04:44 PM |
| What is the while loop even there for... |
|
|
| Report Abuse |
|
|
Dralian
|
  |
| Joined: 21 Mar 2013 |
| Total Posts: 7624 |
|
|
| 08 Oct 2014 04:54 PM |
I think he wants it to repeat it.
but personally, if you want to do it when a player is added use playeradded. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 08 Oct 2014 04:56 PM |
| A touched event already repeats every time its touched |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Oct 2014 05:07 PM |
| Fixed it. I placed the wait() wrong. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 08 Oct 2014 05:08 PM |
local sp, q, p, bounce = script.Parent, "p = ", "q", true
script.Parent.Touched:connect(function(part) if bounce then bounce = false local message = Instance.new("Message", workspace) message.Text = q .. p wait(5) message:Destroy() bounce = true end end) |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2014 05:08 PM |
| and i forgot the if-then return end for debounce, silly me. |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2014 05:09 PM |
| @128 as usual i like yours better. |
|
|
| Report Abuse |
|
|
|
| 08 Oct 2014 05:12 PM |
"local sp, q, p, bounce = script.Parent, "p = ", "q", true"
What does this mean? |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 08 Oct 2014 05:15 PM |
local a = 1 local b = 2 print(a) -->1 print(b) -->2
local a, b = 1, 2 print(a) -->1 print(b) -->2
Just defining variables at the same time to save space It can be useful for more than just saving space though, for swapping values for example
local a, b = 1, 2 print(a) -->1 print(b) -->2
a, b = b, a print(a) -->2 print(b) -->1 |
|
|
| Report Abuse |
|
|
| |
|