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 » Scripting Helpers
Home Search
 

While touched do?

Previous Thread :: Next Thread 
Struanmcd is not online. Struanmcd
Joined: 19 Sep 2008
Total Posts: 369
22 Feb 2013 02:13 PM
At the moment, I am building a model, which has a seat, and some buttons.
I want the buttons to only be able to activate if the person is sat on the seat.
The only problem is, the Touched event only fires once, so I put the question:
Is it possible to do a "While touching do" script, or is it a giant monster of a script, which is too slow for any real applications.

The script would look something like this

function onTouched(hit)
while hit do
if button pressed
//etc

Code above is in pseudo-code, but I want to know if it is hypothetically possible.

Thanks,

Struanmcd
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
22 Feb 2013 02:16 PM
script.Parent.Touched:connect(function(hit)
touching = true
repeat
wait()
--code
until
touching == false
end)

script.Parent.TouchEnded:connect(function()
touching = false
end)
Report Abuse
Struanmcd is not online. Struanmcd
Joined: 19 Sep 2008
Total Posts: 369
22 Feb 2013 02:18 PM
I understand that. I never realised there was a TouchEnded event.
Thanks for your help!
Report Abuse
IJustPwndYou is not online. IJustPwndYou
Joined: 06 Mar 2012
Total Posts: 985
22 Feb 2013 03:08 PM
^^

Problem with that. You need to create the touching variable before the functions.
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
22 Feb 2013 03:11 PM
touching = false

script.Parent.Touched:connect(function(hit)
touching = true
repeat
wait()
--code
until
touching == false
end)

script.Parent.TouchEnded:connect(function()
touching = false
end)
Report Abuse
Struanmcd is not online. Struanmcd
Joined: 19 Sep 2008
Total Posts: 369
22 Feb 2013 05:49 PM
It worked as I had the main script already written, so I just integrated it. But thanks for all the help!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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