|
| 05 May 2014 04:57 PM |
| After using a long script, I can't access script.Parent. It just says " attempt to index field 'Parent' (a nil value)" in the output. I don't know why it does that. Please help. |
|
|
| Report Abuse |
|
|
|
| 05 May 2014 04:59 PM |
| Maybe 'script' is redefined somewhere in the script. If that is the case, an easy fix would be to try Script.Parent |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 05 May 2014 05:02 PM |
| Script is not a valid way to access the script. Can you show us that line? |
|
|
| Report Abuse |
|
|
| |
|
|
| 05 May 2014 05:04 PM |
| "Script" does't work. The line of code is simply "script.Parent:Destroy()". |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 05 May 2014 05:05 PM |
Hmm. I'm scared, but show us every line where you reference "script" (D:)
And yes, I have tried. It was one of my rookie mistakes. |
|
|
| Report Abuse |
|
|
|
| 05 May 2014 05:07 PM |
Yeah..
Happened to me but with game..
heres the line:
"if game.Players.NumPlayers == 2 then"
|
|
|
| Report Abuse |
|
|
|
| 05 May 2014 05:07 PM |
| Ah, the script is already Destroyed. |
|
|
| Report Abuse |
|
|
|
| 05 May 2014 05:07 PM |
| Are you running the script in the CommandBar? |
|
|
| Report Abuse |
|
|
|
| 05 May 2014 05:08 PM |
If you really want to see the full script, here it is:
------------------------------------------ local function WaitFor(parent) return setmetatable({}, { __index = function(tb, child) return function() while not parent:FindFirstChild(child) do parent.ChildAdded:wait() end return parent:FindFirstChild(child) end end; }) end ----------------------------------------
game.Debris:AddItem(script.Parent, 30)
----------------------------------------
local Grenade = script.Parent local GrenadeScript = WaitFor(Grenade).GrenadeScript() local Creator = WaitFor(GrenadeScript).creator().Value local ExplodeSound = WaitFor(Grenade).ExplodeSound() local Character = Creator.Character
---------------------------------------
local Handling = false Grenade.Touched:connect(function(part) --ignore collisions with firer's stuff if Character and part:IsDescendantOf(Character) then return end if Handling then return end Handling = true
--wait a second, this is a grenade so it won't explode on contact wait(3)
--end grenade Grenade.Anchored = true Grenade.CanCollide = false Grenade.Transparency = 1
--play soud ExplodeSound:Play()
--do explode local BlastPart = Instance.new('Part', game.Workspace) BlastPart.FormFactor = 'Custom' BlastPart.Size = Vector3.new(1,1,1) BlastPart.Transparency = 0.3 BlastPart.Anchored = true BlastPart.CanCollide = false BlastPart.CFrame = CFrame.new(Grenade.Position)*CFrame.Angles(-math.pi/2,0,0) local BlastCFrame = CFrame.new(Grenade.Position)*CFrame.Angles(-math.pi/2,0,0) local BlastMesh = Instance.new('SpecialMesh', BlastPart) BlastMesh.MeshId = 'http://www.roblox.com/asset/?id=1080954' BlastMesh.TextureId = 'http://www.roblox.com/asset/?id=37856148' game.Debris:AddItem(BlastPart, 10)
Delay(7*0.03, function() local Explosion = Instance.new('Explosion') Explosion.BlastPressure = 0 Explosion.BlastRadius = 12 Explosion.Position = Grenade.Position -- local HitHumanoidMap = {} Explosion.Hit:connect(function(part, rad) if Character and part:IsDescendantOf(Character) then return end local hum = (part.Parent or game):FindFirstChild('Zombie') if hum and hum.Parent:FindFirstChild('Torso') and not HitHumanoidMap[hum] then HitHumanoidMap[hum] = true hum.Sit = true local tag = GrenadeScript.creator:Clone() tag.Parent = hum game.Debris:AddItem(tag, 2) hum:TakeDamage(100) local twist = Instance.new('BodyAngularVelocity', hum.Parent.Torso) twist.angularvelocity = Vector3.new(10,10,10) local throw = Instance.new('BodyVelocity', hum.Parent.Torso) throw.maxForce = Vector3.new(10000,10000,10000) throw.velocity = (hum.Parent.Torso.Position - Grenade.Position).unit * 40 wait(0.5) twist:Destroy() throw:Destroy() hum.Sit = false end end) -- Explosion.Parent = game.Workspace end) for i = 0, 1, 0.2 do wait() BlastPart.CFrame = CFrame.new(0, math.sqrt(i)*10,0)*BlastCFrame BlastMesh.Scale = Vector3.new(4 + 4*i, 4 + 4*i, 4 + math.sqrt(i)*24) end for i = 0, 1, 0.1 do wait() BlastPart.CFrame = CFrame.new(0,10 - i*i*4,0)*BlastCFrame BlastMesh.Scale = Vector3.new(8 + i*2, 8 + i*2, 28 - i*i*8) BlastPart.Transparency = 0.3 + 0.7*i*i end BlastPart:Destroy()
Grenade:Destroy() script.Parent:Destroy() end)
It's a grenade script. |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 05 May 2014 05:09 PM |
Oof. The reason it's not working is because you're destroying it twice, so of course it won't be there the second time! Here, let me simplify:
local Grenade = script.Parent Grenade:Destroy() script.Parent:Destroy()
You see? |
|
|
| Report Abuse |
|
|
|
| 05 May 2014 05:12 PM |
Instead of script.Parent:Destroy() do if script.Parent then script.Parent:Destroy() end |
|
|
| Report Abuse |
|
|
|
| 05 May 2014 05:13 PM |
| Erm... the line "Grenade:Destroy()" doesn't actually destroy the grenade, it destroys a clone that is used as a bomb for some reason. I don't know why. |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 05 May 2014 05:15 PM |
| You used :clone() once, and it wasn't for the grenade. That's a concern... |
|
|
| Report Abuse |
|
|
|
| 05 May 2014 05:21 PM |
| I'm 97% sure that this script is taken directly from a gear... |
|
|
| Report Abuse |
|
|