TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 06 Dec 2014 04:23 PM |
| I was wondering if there was any way to use a for command to detect if any part in a model was touched by the player? |
|
|
| Report Abuse |
|
|
|
| 06 Dec 2014 04:23 PM |
well a loop might not be the best solution but
for i, v in pairs(thing:GetChildren()) do v.Touched:connect(function(hit) end) end |
|
|
| Report Abuse |
|
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 06 Dec 2014 04:24 PM |
| What would the best solution be then? |
|
|
| Report Abuse |
|
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 06 Dec 2014 04:49 PM |
| What would the best solution be, if for commands aren't the best? |
|
|
| Report Abuse |
|
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 18 Jan 2015 11:52 AM |
| What would the best solution be then? |
|
|
| Report Abuse |
|
|
SLY3
|
  |
| Joined: 10 Jul 2008 |
| Total Posts: 1700 |
|
|
| 18 Jan 2015 11:58 AM |
| A loop is the best solution, you might have to use disconnect if you want them to not connect ontouch after a while though. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 18 Jan 2015 11:59 AM |
This is the best one I can think of
local function onTouch(instance) print(instance.Name) end --[[example function, predefined so it doesn't create a function a ton of times]]
local function connect(instance) if (instance:IsA("BasePart")) then instance.Touched:connect(onTouch) end for _, child in next, instance:GetChildren() do connect(child) end end
connect(workspace.Model) |
|
|
| Report Abuse |
|
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 18 Jan 2015 12:31 PM |
I've been working on this for a while. Would this work?
http://pastebin.com/QNLzFZJS |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 18 Jan 2015 12:37 PM |
No because tables do not have a touched event
Is there something wrong with my script? I typed it on a phone so thereight be a thpe but the idea works |
|
|
| Report Abuse |
|
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 18 Jan 2015 12:46 PM |
| I haven't tested your script out atm. I'll do it now. I was messing around with my script to see if I could get it to work. |
|
|
| Report Abuse |
|
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 18 Jan 2015 12:52 PM |
Another thing I should point out. I'm trying to undo the qPerfectionWeld script that can be found in this model: http://www.roblox.com/item?id=182451181 But I'm also trying to make a model without that weld script fall apart as well. :/ |
|
|
| Report Abuse |
|
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 18 Jan 2015 12:53 PM |
Sorry. The link is actually: http://www.roblox.com/Wooden-Crate-item?id=182451181 :/ |
|
|
| Report Abuse |
|
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 18 Jan 2015 01:01 PM |
| Also, funnily enough, your script combined with Quenty's qPerfectionWeld script, (I forgot to disable the qPerfectionWeldScript.) equals a low gravity effect! It's actually cool. I'll make a model of it for you to see. (http://www.roblox.com/item.aspx?id=205352264) |
|
|
| Report Abuse |
|
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 18 Jan 2015 01:14 PM |
| @128GB, your script doesn't look like it's going to make the model touched fall apart. It seems like the object that touches it will fall apart, and that's not my goal. My goal is to make a model fall apart when touched by a player. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 18 Jan 2015 01:19 PM |
It was an example, it prints the name Change it so it breaks it |
|
|
| Report Abuse |
|
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
| |
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 18 Jan 2015 01:24 PM |
How would I get all the parts in the model and change them at one time? Would I do something like:
parts = script.Parent:GetChildren() parts.--(property) = (true/false) |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 18 Jan 2015 01:27 PM |
local function property(instance, key, value) pcall(function() instance[key] = value; end) for _, child in next, instance:GetChildren() do property(child, key, value) end end
property(workspace.Model, "BrickColor", BrickColor.new("Bright red")) |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 18 Jan 2015 01:28 PM |
local changes = { ["Size"] = {true,Vector3.new()}, ["BrickColor"] = {true,BrickColor.new()}, ["CFrame"] = {false,CFrame.new()}, ["Anchored"] = {true,true} }
function change(part) for i,v in pairs(changes) do if part[i] then part[i] = v or nil end end end
function changeAll(model) for i,v in pairs(model:GetChildren()) do if v:IsA("BasePart") then change(v) end changeAll(v) end end
changeAll(workspace.Model); |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 18 Jan 2015 01:30 PM |
I'm high
local changes = { ["Size"] = {true,Vector3.new()}, ["BrickColor"] = {true,BrickColor.new()}, ["CFrame"] = {false,CFrame.new()}, ["Anchored"] = {true,true} }
function change(part) for i,v in pairs(changes) do if v[1] == true then if part[i] then part[i] = v[2] or nil end end end end
function changeAll(model) for i,v in pairs(model:GetChildren()) do if v:IsA("BasePart") then change(v) end changeAll(v) end end
changeAll(workspace.Model);
|
|
|
| Report Abuse |
|
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 18 Jan 2015 01:32 PM |
| What would the local change array entry be for surfaces/surfacetypes? |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 18 Jan 2015 01:36 PM |
["TopSurface"] = {true,"Smooth"}
The bool(true or false), as the first table index is whether or not to use this change, the second table index(smooth) is what to change the property to. |
|
|
| Report Abuse |
|
|
TheMcInc
|
  |
| Joined: 30 Sep 2012 |
| Total Posts: 227 |
|
|
| 18 Jan 2015 01:38 PM |
| Oh. Got it! Thx. Hopefully I can pull this together soon. I've been at my computer since 9:00AM Central Time, and its now 1:37PM Central Time. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 18 Jan 2015 02:24 PM |
I would suggest using mine I'm not trying to be rude sorry Goul |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 18 Jan 2015 02:25 PM |
But 128.. urs it h0t but you have to be liek 10 lines of calling teh function for different properties.
<3 |
|
|
| Report Abuse |
|
|