Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-6

CASE CLOSED YES?

Asked by 9 years ago

make = script.Parent head = make:findFirstChild("HeadWeld") leftarm = make:findFirstChild("LeftArmWeld") rightarm = make:findFirstChild("RightArmWeld") leftleg = make:findFirstChild("LeftLegWeld") rightleg = make:findFirstChild("RightLegWeld") torso = make:findFirstChild("TorsoWeld") npc = script.Parent:FindFirstChild("NPC-Armor") p = script.Parent.Parent.Parent char = script.Parent.Parent.Parent.Character --[[part = script.Parent:FindFirstChild("Activate") touch = false

if part == nil then repeat wait() until char -- waits until player actually exists touch.Value = true elseif part ~= nil then part.Touched:connect(function(hit) h = hit.Parent:findFirstChild("Humanoid") if h ~= nil then touch.Value = true end end) end]]

repeat wait() until char

if head ~= nil then head2 = head:Clone() head2.Parent = p.Character weld1 = Instance.new("Weld", head2:findFirstChild("Handle")) weld1.Part0 = head2:findFirstChild("Handle") weld1.Part1 = p.Character:findFirstChild("Head") if npc ~= nil then if npc.Value == true then npcchar = workspace:GetChildren() for c = 1, #npcchar do if npcchar[c].ClassName == "Model" then hum = npcchar[c]:findFirstChild("Humanoid") if hum ~= nil then npcheadfind = hum.Parent:findFirstChild("Head") if npcheadfind ~= nil then clean1 = hum.Parent:findFirstChild("HeadWeld") if clean1 ~= nil then clean1:Remove() end npchead = head:Clone() npchead.Parent = hum.Parent npcweld1 = Instance.new("Weld", npchead:findFirstChild("Handle")) npcweld1.Part0 = npchead:findFirstChild("Handle") npcweld1.Part1 = hum.Parent:findFirstChild("Head") end end end end end end end if leftarm ~= nil then leftarm2 = leftarm:Clone() leftarm2.Parent = p.Character weld2 = Instance.new("Weld", leftarm2:findFirstChild("Handle")) weld2.Part0 = leftarm2:findFirstChild("Handle") weld2.Part1 = p.Character:findFirstChild("Left Arm") if npc ~= nil then if npc.Value == true then npcchar = workspace:GetChildren() for c = 1, #npcchar do if npcchar[c].ClassName == "Model" then hum = npcchar[c]:findFirstChild("Humanoid") if hum ~= nil then npcleftarmfind = hum.Parent:findFirstChild("Left Arm") if npcleftarmfind ~= nil then clean2 = hum.Parent:findFirstChild("LeftArmWeld") if clean2 ~= nil then clean2:Remove() end npcleftarm = leftarm:Clone() npcleftarm.Parent = hum.Parent npcweld2 = Instance.new("Weld", npcleftarm:findFirstChild("Handle")) npcweld2.Part0 = npcleftarm:findFirstChild("Handle") npcweld2.Part1 = hum.Parent:findFirstChild("Left Arm") end end end end end end end if rightarm ~= nil then rightarm2 = rightarm:Clone() rightarm2.Parent = p.Character weld3 = Instance.new("Weld", rightarm2:findFirstChild("Handle")) weld3.Part0 = rightarm2:findFirstChild("Handle") weld3.Part1 = p.Character:findFirstChild("Right Arm") if npc ~= nil then if npc.Value == true then npcchar = workspace:GetChildren() for c = 1, #npcchar do if npcchar[c].ClassName == "Model" then hum = npcchar[c]:findFirstChild("Humanoid") if hum ~= nil then npcrightarmfind = hum.Parent:findFirstChild("Right Arm") if npcrightarmfind ~= nil then clean3 = hum.Parent:findFirstChild("RightArmWeld") if clean3 ~= nil then clean3:Remove() end npcrightarm = rightarm:Clone() npcrightarm.Parent = hum.Parent npcweld3 = Instance.new("Weld", npcrightarm:findFirstChild("Handle")) npcweld3.Part0 = npcrightarm:findFirstChild("Handle") npcweld3.Part1 = hum.Parent:findFirstChild("Right Arm") end end end end end end end if leftleg ~= nil then leftleg2 = leftleg:Clone() leftleg2.Parent = p.Character weld4 = Instance.new("Weld", leftleg2:findFirstChild("Handle")) weld4.Part0 = leftleg2:findFirstChild("Handle") weld4.Part1 = p.Character:findFirstChild("Left Leg") if npc ~= nil then if npc.Value == true then npcchar = workspace:GetChildren() for c = 1, #npcchar do if npcchar[c].ClassName == "Model" then hum = npcchar[c]:findFirstChild("Humanoid") if hum ~= nil then npcleftlegfind = hum.Parent:findFirstChild("Left Leg") if npcleftlegfind ~= nil then clean4 = hum.Parent:findFirstChild("LeftLegWeld") if clean4 ~= nil then clean4:Remove() end npcleftleg = leftleg:Clone() npcleftleg.Parent = hum.Parent npcweld4 = Instance.new("Weld", npcleftleg:findFirstChild("Handle")) npcweld4.Part0 = npcleftleg:findFirstChild("Handle") npcweld4.Part1 = hum.Parent:findFirstChild("Left Leg") end end end end end end end if rightleg ~= nil then rightleg2 = rightleg:Clone() rightleg2.Parent = p.Character weld5 = Instance.new("Weld", rightleg2:findFirstChild("Handle")) weld5.Part0 = rightleg2:findFirstChild("Handle") weld5.Part1 = p.Character:findFirstChild("Right Leg") if npc ~= nil then if npc.Value == true then npcchar = workspace:GetChildren() for c = 1, #npcchar do if npcchar[c].ClassName == "Model" then hum = npcchar[c]:findFirstChild("Humanoid") if hum ~= nil then npcrightlegfind = hum.Parent:findFirstChild("Right Leg") if npcrightlegfind ~= nil then clean5 = hum.Parent:findFirstChild("RightLegWeld") if clean5 ~= nil then clean5:Remove() end npcrightleg = rightleg:Clone() npcrightleg.Parent = hum.Parent npcweld5 = Instance.new("Weld", npcrightleg:findFirstChild("Handle")) npcweld5.Part0 = npcrightleg:findFirstChild("Handle") npcweld5.Part1 = hum.Parent:findFirstChild("Right Leg") end end end end end end end if torso ~= nil then torso2 = torso:Clone() torso2.Parent = p.Character weld6 = Instance.new("Weld", torso2:findFirstChild("Handle")) weld6.Part0 = torso2:findFirstChild("Handle") weld6.Part1 = p.Character:findFirstChild("Torso") if npc ~= nil then if npc.Value == true then npcchar = workspace:GetChildren() for c = 1, #npcchar do if npcchar[c].ClassName == "Model" then hum = npcchar[c]:findFirstChild("Humanoid") if hum ~= nil then npctorsofind = hum.Parent:findFirstChild("Torso") if npctorsofind ~= nil then clean6 = hum.Parent:findFirstChild("TorsoWeld") if clean6 ~= nil then clean6:Remove() end npctorso = rightleg:Clone() npctorso.Parent = hum.Parent npcweld6 = Instance.new("Weld", npctorso:findFirstChild("Handle")) npcweld6.Part0 = npctorso:findFirstChild("Handle") npcweld6.Part1 = hum.Parent:findFirstChild("Torso") end end end end end end end AW = make:findFirstChild("ArmorWeight") if AW ~= nil then ss = AW:Clone() ss.Parent = p.Character ss.Disabled = false end WN = make:findFirstChild("WeightNumber") if WN ~= nil then WN:Clone().Parent = p.Character end

-- I put the armor in the starter pack and named it Heavy Steel Armour And put this script into it and it worked.. Also I welded each part of the armor named it and stuff and each part of the armor is in a model...

0
or when you die and respawn User#7446 0 — 9y

2 answers

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

Please don't request here, this isn't a request site.

But other than that, I will answer your question. To do what you're trying to accomplish you'll need to have good understanding of PlayerAdded Events, CharacterAdded Events, Welding, Cloning, and CFrame.

First, you're going to want to set up variables for your armour items

local helmet = game.ServerStorage:FindFirstChild("Helmet")
local chestPlate = game.ServerStorage:FindFirstChild("ChestPlate")

Next, you have to set a PlayerAdded Event, to define when the player joins.

game.Players.PlayerAdded:connect(function(player)

Followed by a CharacterAdded Event, using the Parameter from the PlayerAdded Event.

plr.CharacterAdded:connect(function(char)

Then you need to clone the chestPlate and Helmet into the character and weld them, then unanchor them. But first you're probably going to want to wait until the Torso of the Character exists, just so we don't get any errors like: Attempt to index a nil value.

char:WaitForChild("Torso")
--Check if the chestPlate exists--
if chestPlate then
    --Clone plate into character--
    local newPlate = chestPlate:Clone()
    newPlate.Parent = char
    --Get a random part to be the base of the weld--
    local newPlateC = newPlate:GetChildren()
    local base = newPlateC[math.random(1,#newPlateC)]
    --Weld the randompart to the Torso of the Character--
    local weld = Instance.new("Weld",base)
    weld.Part0 = base
    weld.Part1 = char.Torso
    --Unanchor whole chestplate--
    local unanchor = function(model)
        for i,v in pairs(model:GetChildren()) do
            if v:IsA("BasePart") then
                v.Anchored = true
            end
            if #v:GetChildren > 0 then
                unanchor(v)
            end
        end
    end
end

Note: This is only a guideline, not an exact script. I'm just showing you the steps that it takes to do what you're trying to accomplish.

So the whole outcome will look similiar to this:

local helmet = game.ServerStorage:FindFirstChild("Helmet")
local chestPlate = game.ServerStorage:FindFirstChild("ChestPlate")

game.Players.PlayerAdded:connect(function(player)
    plr.CharacterAdded:connect(function(char)
        char:WaitForChild("Torso")
        if chestPlate then
            local newPlate = chestPlate:Clone()
            newPlate.Parent = char
            local newPlateC = newPlate:GetChildren()
            local base = newPlateC[math.random(1,#newPlateC)]
            local weld = Instance.new("Weld",base)
            weld.Part0 = base
            weld.Part1 = char.Torso
            local unanchor = function(model)
                for i,v in pairs(model:GetChildren()) do
                    if v:IsA("BasePart") then
                        v.Anchored = true
                    end
                    if #v:GetChildren > 0 then
                        unanchor(v)
                    end
                end
            end
        end
    end)
end)
0
I put the armor in ServerStorage then named it ChestPlate and put that script in a local script and I checked over the script 1 more time and where it says if # :GetChildren > 0 then where the > is it was underlined red.... User#7446 0 — 9y
0
Please re-read.. about halfway through my answer.. 'Note: This is only a guideline, not an exact script. I'm just showing you the steps that it takes to do what you're trying to accomplish.' Goulstem 8144 — 9y
0
I fixed it myself.. User#7446 0 — 9y
Ad
Log in to vote
-4
Answered by 9 years ago

you clearly didnt read the rules you need to provide some form of script that you have tried, personally i think this rule is stupid but message me on roblox my name is raymandon and i will message you the script

Answer this question