tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 16 Oct 2013 09:18 PM |
I made a script for an object that locks things that come in contact with it... however, it dosen't lock anything. There's also a print command which works fine; this tells me that it's recognizing the collision. Here's the code:
function onTouched(hit) hit.Locked = true print 'Locked Part!' end script.Parent.Touched:connect(onTouched)
Whats wrong? |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
| |
|
|
| 16 Oct 2013 09:31 PM |
Try defining the part with
part = script.Parent
I think with "hit" you are locking the part that touches the brick. Or is that what your trying to do? |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 16 Oct 2013 09:33 PM |
yea, I want it to lock parts that touch it.
Oh, and it's moving down with a TranslateBy command... does that screw up the collision detection? |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 09:35 PM |
does translateby use cframe
cframe doesn't really cooperate with touched very well iirc |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 16 Oct 2013 09:38 PM |
| Well, I hafta use c-framing (TranslateBy in this case). If I don't, the part will get stuck on everything and it won't lock your creations. |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
| |
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
|
| 16 Oct 2013 09:48 PM |
| I think you're confusing 'Locked' and 'Anchored'. Locked determines whether or not the Part can be selected by Studio tools, Anchored determines whether or not it is effected by physics. |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 16 Oct 2013 09:50 PM |
| Okay, maybe I should explain to you what I need. I'm making a building game. In each building area, given to each player, there will be a button. Pressing this button causes an invisible and canCollide false brick to dash through the room, locking anything in it's path. The object uses the TranslateBy command to move down -2 studs pere 0.01 seconds and it returns to its original position in 10 seconds. |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 16 Oct 2013 09:51 PM |
*to move down 2 seconds *per 0.01 seconds
I hate typos... ._. |
|
|
| Report Abuse |
|
|
Ekkoh
|
  |
| Joined: 22 Oct 2012 |
| Total Posts: 524 |
|
|
| 16 Oct 2013 09:53 PM |
Why not just loop through the model and lock everything...
"To sing when you live and to sing when you die" - George Ragan |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 09:55 PM |
use this function
function lock(t) for i,v in ipairs(t:GetChildren()) do pcall(function() v.Locked = true end) lock(v) end end |
|
|
| Report Abuse |
|
|
Ekkoh
|
  |
| Joined: 22 Oct 2012 |
| Total Posts: 524 |
|
|
| 16 Oct 2013 09:57 PM |
Or better yet
local function lock(model) for _, obj in pairs(model:GetChildren()) do if obj:IsA("BasePart") then obj.Locked = true end lock(obj) end end
"To sing when you live and to sing when you die" - George Ragan |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 09:57 PM |
actually wait that would take a little bit more work to implement in your place use findpartsinregion3 to get all of the parts inside the building area then lock them http://wiki.roblox.com/index.php/FindPartsInRegion3_(Method) |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 16 Oct 2013 09:58 PM |
| I have no knowledge in functions... do I replace the old lock script with this, or do I sandwich it between the onTouched command? |
|
|
| Report Abuse |
|
|
Ekkoh
|
  |
| Joined: 22 Oct 2012 |
| Total Posts: 524 |
|
|
| 16 Oct 2013 09:58 PM |
Or if he parented all copied parts to a model for each user with a custom copy tool it would make things a whole lot easier.
"To sing when you live and to sing when you die" - George Ragan |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 09:59 PM |
| @ekkoh yeah but im going to assume he doesn't want to do extra work for that |
|
|
| Report Abuse |
|
|
Ekkoh
|
  |
| Joined: 22 Oct 2012 |
| Total Posts: 524 |
|
|
| 16 Oct 2013 10:00 PM |
@tinarg I'd try to find a different way before you resort to that. Trust me, that's the last method you'd wanna use to accomplish this.
"To sing when you live and to sing when you die" - George Ragan |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 16 Oct 2013 10:00 PM |
| No fancy region stuff... I need this code to work with 6 different bases, all in different locations. What is the easiest way I can do this effectively? and I have no clue what half the stuff your talking about is... :\ |
|
|
| Report Abuse |
|
|
Ekkoh
|
  |
| Joined: 22 Oct 2012 |
| Total Posts: 524 |
|
|
| 16 Oct 2013 10:03 PM |
If I were you I'd find a decent scripter who is willing to help you with your game, it's going to be the easiest if they have a copy of your game so they can see the layout of everything and determine what the best way is.
"To sing when you live and to sing when you die" - George Ragan |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 10:03 PM |
the easiest way is a combination of the lock function and ekkoh's idea of using a modified copy tool you would have the copy tool parent everything to a model assigned to a player then evoke the lock function by typing lock(the location of the model storing the parts)
there's not really an easy easy way to do it but yeah |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 16 Oct 2013 10:04 PM |
| But this is the only problem I have... I'm just asking what I put in place for the lock on touch script. |
|
|
| Report Abuse |
|
|
Ekkoh
|
  |
| Joined: 22 Oct 2012 |
| Total Posts: 524 |
|
|
| 16 Oct 2013 10:06 PM |
@tinarg BRUH, scrap the "on touch" script. That idea is not going to produce the results you want. I'll fix something up for you for a price if you're interested, but I'm not going to waste my time just so you can make more money and credits for yourself.
"To sing when you live and to sing when you die" - George Ragan |
|
|
| Report Abuse |
|
|
tinarg
|
  |
| Joined: 18 Jun 2010 |
| Total Posts: 4925 |
|
|
| 16 Oct 2013 10:09 PM |
| *Sigh* I'm not trying to be one of those people, even if it looks like it. I'll just go dissect some random model and see what that does. |
|
|
| Report Abuse |
|
|
|
| 16 Oct 2013 10:10 PM |
tinarg you could use bodyvelocity or bodyposition to move the brick instead of translating it with cframe so the touched event would work
not very efficient but it should work decently if the brick is moving slowly |
|
|
| Report Abuse |
|
|