Splashsky
|
  |
| Joined: 30 Aug 2008 |
| Total Posts: 1102 |
|
|
| 02 Apr 2014 02:50 PM |
I've trying to create a library script for my RPG... the respawn function gives me an issue when I attempt to look for hats.
RPGLib.RespawnMob = function(Replacement, BodyParts) -- Get rid of pesky things. BodyParts["FakeHead"].MobGUI:remove() BodyParts["LeftArm"].DamageScript:remove() BodyParts["RightArm"].DamageScript:remove() BodyParts["Head"]:remove() -- Fade away all body parts, then delete them. local parts = {} -- Array/table to hold body parts. -- We're grabbing all the parts in the mob's model. for _,v in pairs(script.Parent.Parent:GetChildren()) do if v:IsA("Hat") then -- error occurs here -- It's a hat check, in case anything is a handle brick. table.insert(parts, v.Handle) elseif v:IsA("Part") then -- For normal parts. table.insert(parts, v) end end wait(1) for i = -0.03, 1.04, 0.05 do -- This will send the blocks through a loop for transparency; makes a fading effect. for _,v in pairs(parts) do v.Transparency = i -- Changes each block's transparency! end wait(0.1) end -- Deleting all body parts for cleanliness. BodyParts["Torso"]:remove() BodyParts["LeftArm"]:remove() BodyParts["LeftLeg"]:remove() BodyParts["RightArm"]:remove() BodyParts["RightLeg"]:remove() BodyParts["FakeHead"]:remove() -- Wait four seconds wait(4) -- Clone the mob. Enemy = Replacement:clone()
-- Let's set the mob back in the world! Enemy.Parent = script.Parent.Parent.Parent -- Let's make it's joints. Enemy:makeJoints() end |
|
|
| Report Abuse |
|
Splashsky
|
  |
| Joined: 30 Aug 2008 |
| Total Posts: 1102 |
|
|
| 02 Apr 2014 03:03 PM |
| Is it an issue with the IsA() function... or the loop for getting children? |
|
|
| Report Abuse |
|