How do i make a button like that where it spawn a sphere

does anyone know to make a button like that, anything will help.

local part = -- The part you want to click in order to spawn a sphere.

part.Touched:Connect(function(object) -- A touched function
      -- You can check to see if the object is a character here, not going to bother.
      local sphere ='Part')
      sphere.Size =, 1, 1) -- Size, 1 is 1 stud by 1 stud.
      sphere.Shape = Enum.PartType.Sphere -- Make it a sphere
      sphere.Position =, 10, 0) -- Position it
      sphere.Parent = workspace -- Parent it

Would add a debounce to prevent spamming spheres.

1 Like

Here’s a script that I would do:

local button = script.Parent
local debounce = true
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
       if debounce then
          debounce = false
    local sphere ="Part")
    sphere.Parent = workspace
    local mesh ="Mesh")
    mesh.Parent = sphere
    mesh.whatever = "Sphere" --I don't have Roblox studio to use this lol.
    sphere.Position =,y,z)
    sphere.Anchored = false
    sphere.Size =,5,5)
    button.Position = button.Position +,-0.5,0)
    button.BrickColor ="Bright green")
    button.Position = button.Position +,0.5,0)
    button.BrickColor ="Really red")
    debounce = true

Also, thank you for teaching me “.Shape”, didn’t know I could use an Enum for that.

1 Like

A simple way would be to first position a sphere in the workspace to where you want it to be spawned at, place it in ServerStorage, and do a script like this

local part = script.Parent
local sphere = game:GetService("ServerStorage").Sphere

local deb = false

	local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if not plr or deb then return end
	deb = true
	part.BrickColor = BrickColor.Red()
	local sphereClone = sphereClone:Clone()
	sphereClone.Parent = workspace
	sphereClone.Anchored = false
	part.BrickColor = BrickColor.Green()
	deb= false

It works like this

When something hits the button, check if it belongs to a player, if it doesn’t or button cannot be used yet, do not continue. If it can be used, set the debounce to true, set the BrickColor to red, clone the sphere and unanchor and parent it to workspace (which should hopefully position it where you placed it before sending to ServerStorage) wait 5 seconds, and then set the brickcolor to green and debounce to false, allowing it to be used again.

You could create the sphere yourself in the code, but I just wanted to also mention another method you could do it


So i insert a local script into my button add the code, and put a Sphere in serverstorage

am i reading that right?

You put a regular script into the button, position a sphere where you want it to spawn at, anchor it, and put it in ServerStorage

1 Like