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

Someone help with a button that spawns humans? [closed]

Asked by 1 year ago
Edited by ScriptGuider 1 year ago

I have a button that should spawn a human on a part named "Hspawn" When i press it the sounds go off and everything although no human spawns. Here's the script:

room = script.Parent.Parent.Parent.Parent

enums = {"Doug","Jhonatam","Johan","Rob","Robson","Hiron","Kleb","Kurt","Fernand","Jefferson","Jackson","Jake","Jack","Mason","Jamal","Mateo","Noah","Lucas","David","Albert","George","Nicholas","Gabriel","Peter","Alfred","Josef","Erick","Dylan","John","Gustav","Richard","Ron","June"}
enums2 = {BrickColor.new("Pastel brown"),BrickColor.new("Brick yellow"),BrickColor.new("Pine Cone"),BrickColor.new("Dirt brown"),BrickColor.new("Wheat")}
script.Parent.ClickDetector.MouseClick:connect(function()
if not room.Human:FindFirstChildOfClass("Model") then
    local color = enums2[math.random(1,#enums2)]
    script.Parent.Sound:Play()
        local human = game.Lighting.Human:Clone()
    for i,v in pairs(human:GetChildren()) do
        if v:IsA("Part") then
            v.BrickColor = color
        end
    end

    human.Name = enums[math.random(1,#enums)]
    human.Parent = room.Human
    human:MakeJoints()
human.HumanoidRootPart.CFrame = room.Hspawn.CFrame
wait(0.5)
room.Ground.hit:Play()
end
end)

am i missing something?

0
This question is a bit too broad to answer without someone re-writing all of the code. I would recommend that you try and break your problem down into smaller components which you can then ask about. Best of luck! ScriptGuider 5640 — 1y

Closed as Too Broad by ScriptGuider

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?