Scripting problem with bot

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

i want to make a gui when you click it it spawns a bot from lighting

  1. What is the issue? Include screenshots / videos if possible!

the bot is not showing in the game when i try

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

i ask gtp if the are mispelling or what the problem was

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local button = script.Parent

button.MouseButton1Click:Connect(function()
    local bot = Instance.new("Model")
    bot.Name = "Bot"
    bot.Parent = game.Workspace

    local humanoid = Instance.new("Humanoid")
    humanoid.Name = "BotHumanoid"
    humanoid.Parent = bot

    local part = Instance.new("Part")
    part.Name = "Head"
    part.Size = Vector3.new(1, 1, 1)
    part.Parent = bot

    local mesh = Instance.new("SpecialMesh")
    mesh.MeshType = Enum.MeshType.Head
    mesh.Parent = part
end)

image
image

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Is the script located in the button or outside of it? If it is located outside of it, then change this line to script.Parent:WaitForChild("Button")

I dont understand why do you mean by inside or outside and where should I put that code

Put the script object inside the TextButton object.