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 » Scripters
Home Search
 

Re: I really need help! URGENT please respond

Previous Thread :: Next Thread 
NotTrade is not online. 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 is not online. NotTrade
Joined: 02 Feb 2016
Total Posts: 1225
15 May 2016 04:30 PM
What am I not seeing


Report Abuse
GetTheJobDone is not online. GetTheJobDone
Joined: 20 Apr 2016
Total Posts: 3008
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 is not online. NotTrade
Joined: 02 Feb 2016
Total Posts: 1225
15 May 2016 04:33 PM
Please...


Report Abuse
GetTheJobDone is not online. GetTheJobDone
Joined: 20 Apr 2016
Total Posts: 3008
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 is not online. 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
GetTheJobDone is not online. GetTheJobDone
Joined: 20 Apr 2016
Total Posts: 3008
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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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