NotTrade
|
  |
| Joined: 02 Feb 2016 |
| Total Posts: 1225 |
|
|
| 15 May 2016 04:27 PM |
So it works fine and prints a message "You lost!"
but then it won't remove the message
function onTouch(part) h = part.Parent:findFirstChild("Humanoid") if h ~= nil then h:remove() end end
script.Parent.Touched:connect(onTouch)
function onTouch2(part) m = Instance.new("Message") m.Parent = game.Workspace m.Text = "You lost!" m.Name = "Test" wait(4) m:Remove() end
script.Parent.Touched:connect(onTouch2)
|
|
|
| Report Abuse |
|
|
NotTrade
|
  |
| Joined: 02 Feb 2016 |
| Total Posts: 1225 |
|
| |
|
|
| 15 May 2016 04:33 PM |
I believe it's a problem with you declaring m as a global variable with no proper debounce on the Touched event.
|
|
|
| Report Abuse |
|
|
NotTrade
|
  |
| Joined: 02 Feb 2016 |
| Total Posts: 1225 |
|
| |
|
|
| 15 May 2016 04:33 PM |
Honestly there's nothing else I see that it could be, if someone else sees something reply, but this seems to be an almost sure case of problems with scoping. Also, Remove() is deprecated, you should probably use Destroy().
|
|
|
| Report Abuse |
|
|
NotTrade
|
  |
| Joined: 02 Feb 2016 |
| Total Posts: 1225 |
|
|
| 15 May 2016 04:37 PM |
Wait, It actually repeats the message text a few times So when I remove it, there are like 4 other messages
i think i have an idea to solve it
|
|
|
| Report Abuse |
|
|
|
| 15 May 2016 04:38 PM |
I was right.
Use a local variable for the m, and please use better variable names, like "message" instead of "m". Good luck!
|
|
|
| Report Abuse |
|
|
NotTrade
|
  |
| Joined: 02 Feb 2016 |
| Total Posts: 1225 |
|
|
| 15 May 2016 04:40 PM |
Oh no wait, I think I got it.
As the humanoid removes, the body parts are still touching the brick which is causing the message to pop up, let me see
|
|
|
| Report Abuse |
|
|
NotTrade
|
  |
| Joined: 02 Feb 2016 |
| Total Posts: 1225 |
|
|
| 15 May 2016 04:44 PM |
fixed it
function onTouch(part) h = part.Parent:findFirstChild("Humanoid") if h ~= nil then h:remove() end end
script.Parent.Touched:connect(onTouch)
function onTouch2(part) wait(2) game.Workspace.josh:Remove() m = Instance.new("Message") m.Parent = game.Workspace m.Text = "You lost!" m.Name = "Lost" wait(4) m:Destroy() n = part.Parent:findFirstChild("Message") if n ~= nil then n:Destroy() end end
script.Parent.Touched:connect(onTouch2)
it created Message each time the body touched the brick, and after humanoid was removed, body parts kept touching the brick..
So I removed the brick to prevent that
Thanks for the help!
|
|
|
| Report Abuse |
|
|