|
| 02 Apr 2012 08:48 PM |
script.Parent.Touched:connect(function(hit) if hit.Parent["Humanoid"] then local g=hit.Parent.Name local h=game.Players[g].Backpack:GetChildren() for i=1, #h do if h[i]:IsA("Tool") and h[i].Name == "Gun" then h[i]:Destroy() end end end
I was never good at makeing them |
|
|
| Report Abuse |
|
|
|
| 02 Apr 2012 08:54 PM |
script.Parent.Touched:connect(function(hit) if hit.Parent["Humanoid"] then local g=hit.Parent.Name local h=game.Players[g].Backpack:GetChildren() for i=1, #h do if h[i]:IsA("Tool") and h[i].Name == "Gun" then h[i]:Destroy() end end end end) |
|
|
| Report Abuse |
|
|
Defendur
|
  |
| Joined: 31 Mar 2012 |
| Total Posts: 40 |
|
|
| 02 Apr 2012 09:48 PM |
Can you tell me why you use :connect(function(hit)
instead of
function touched(hit) if hit.Parent["Humanoid"] then local g=hit.Parent.Name local h=game.Players[g].Backpack:GetChildren() for i=1, #h do if h[i]:IsA("Tool") and h[i].Name == "Gun" then h[i]:Destroy() end end end end
script.Parent.Touched:connect(touched)
I'm being serious, this must be something new in the past few years. :o |
|
|
| Report Abuse |
|
|
|
| 02 Apr 2012 09:54 PM |
| No it isn't, it's called an anonymous function. As the name suggests, it's an unnamed function. |
|
|
| Report Abuse |
|
|
Defendur
|
  |
| Joined: 31 Mar 2012 |
| Total Posts: 40 |
|
|
| 02 Apr 2012 09:59 PM |
| I'm pretty sure it's new.. We never had these in 08. |
|
|
| Report Abuse |
|
|
|
| 02 Apr 2012 10:01 PM |
| Its becasue the scripts are becomeing more bigger and better, so its a way so the scripts can go easyer. |
|
|
| Report Abuse |
|
|
|
| 02 Apr 2012 10:04 PM |
@ElectricBlaze you script works, but still disconects after one hit. |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2012 05:07 PM |
@Defendur - I was here in 2008 too, I would know. Also, Anonymous Functions are something that were not created by ROBLOX - they're from Lua. I'm not even sure ROBLOX *can* get rid of anonymous functions, as technically, all functions are anonymous. What I mean by that is that when you give a function a name, you're really only creating a variable and putting the function inside. Try this:
(function() print"Hello World!" end)()
It works just as well as:
function hello() print"Hello World!" end hello() |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2012 05:12 PM |
@unknown - Of course it disconnects after one hit, after it deletes your guns, you don't have them anymore. I'm just going to rewrite your code to make it look better.
local deb = false script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and not deb then deb = true for k,v in pairs(game.Players[hit.Parent.Name].Backpack:GetChildren()) do if v:IsA("Tool") and v.Name == "Gun" then v:Destroy() end end end wait(1) deb = false end) |
|
|
| Report Abuse |
|
|