|
| 07 Apr 2014 03:26 PM |
Hi, I am trying to make it so I can have an efficient way of putting a touched event into multiple parts, whilst only using one script. I think it's possible but I'm not sure. I have made a script to find out if this works, but it is not working, and I think it's something to do with the touched event on the third line I put in. Can anyone help me debug my script, any help is appreciated. Thanks! (PS: I looked in the output but it gives no errors, so I'm stumped.)
Script:
for i,v in pairs(script.Parent:GetChildren()) do if not v:IsA("Script") and not script.Parent:FindFirstChild("Explosion") and v.Transparency == 0 then v.Touched:connect(function(hit) local h = hit.Parent:FindFirstChild("Humanoid") if h and h.Parent:FindFirstChild("Aura") then local ex = Instance.new("Explosion", script.Parent) local pos = script.Parent:GetModelCFrame() ex.BlastPressure = 0 ex.BlastRadius = 10 ex.Position = pos.p for _,part in pairs(script.Parent:GetChildren()) do if not part:IsA("Explosion") or not part:IsA("Script") then part.CanCollide = false part.Transparency = 1 end end wait(2) ex:Remove() wait(60*2) for _,parts in pairs(script.Parent:GetChildren()) do if not parts:IsA("Explosion") or not parts:IsA("Script") then parts.CanCollide = true parts.Transparency = 0 end end end end) end end
When life gives you lemons... BURN HIS HOUSE DOWN! >:D |
|
|
| Report Abuse |
|
|
|
| 07 Apr 2014 04:53 PM |
Bump?
When life gives you lemons... BURN HIS HOUSE DOWN! >:D |
|
|
| Report Abuse |
|
|
Havemeat
|
  |
| Joined: 08 Jan 2008 |
| Total Posts: 18081 |
|
|
| 07 Apr 2014 04:58 PM |
Are there any errors in the output? If so, can you paste them here?
Happy Scripting! Havemeat |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2014 10:04 AM |
@Have There's no errors on the output window. I'm kind of stumped.
When life gives you lemons... BURN HIS HOUSE DOWN! >:D |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2014 10:08 AM |
while wait() do for I,v in pairs(script.Parent:GetChildren()) do ypcall(function() if v.Transparency == 0 and not script.Parent:findFirstChild("Explosion") then v.Touched:connect(function(h) if h.Parent:findFirstChild("Humanoid") then --boommm end end end)
|
|
|
| Report Abuse |
|
|
|
| 08 Apr 2014 10:21 AM |
Ah, thanks island. I've never experimented with ypcall before, but still, thanks!
When life gives you lemons... BURN HIS HOUSE DOWN! >:D |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2014 10:24 AM |
One question though, is the while wait() do at the start necessary?
When life gives you lemons... BURN HIS HOUSE DOWN! >:D |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2014 10:25 AM |
hint:when using ypcall(
its always
ypcall(function() --code end)
so like..
ypcall(function() prinnnnnnnnnntttttt("sup[") print "hi" end)
output should show hi |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2014 10:26 AM |
the while wait? yes,very necessary..
otherwise,it instantly loops thru the objects,creates the touched event,ignores it and goes to next
looping it makes them all be able to be touched,otherwise it only runs once |
|
|
| Report Abuse |
|
|
|
| 08 Apr 2014 10:28 AM |
@island Alright. I'm going to try and use debounce with that script. Thanks.
When life gives you lemons... BURN HIS HOUSE DOWN! >:D |
|
|
| Report Abuse |
|
|