Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a ball that when it disappears, it creates a new one?

I am making a minigame thing where where players are spawned, there's multiple places they can hide, while a ball rolls down a hill and if the player is hit they die. How to I make sure the ball is created over and over? Here's my attempt (im awful at scripting):

ball = game.Workspace.Ball

wait(3)

Instance.new("Ball")

ball.Position = Vector3.new( x, y, z)

ball.Anchored = false

2 comments

0

kms

0

I'm sorry dude, there is not much to work with here. Please try to read some scripting tutorials first.

1 answer

✓ Accepted answer

"Ball" isn't something Lua can recognize. Instead, you can set the shape after you create the standard part itself.

-- Search for the first Ball
ball = game.Workspace:WaitForChild('Ball')

wait(3)

-- Create a Brick, then set it's shape to Ball
local newball Instance.new('Part', game.Workspace)
newball.Name = 'InstancedBall' -- Set a new name for the part
newball.Shape = 'Ball' 
newball.Position = Vector3.new(x,y,z) 

ball:Destroy() -- You can destroy something by addressing it with :Destroy()

To have this repeat over and over, you can put the bottom part in a function and then create a loop that triggers said function every (x) seconds.

Another way that you could do this could be using clones.

-- Have a ball already somewhere in the workspace
ball = game.Workspace:WaitForChild('Ball')

wait(3)

-- Create a clone of it, then make the clone do what you want
local cball = ball:Clone()
cball.Parent = game.Workspace
cball.Position = Vector3.new(x,y,z)

1 comment

0

the second argument for instance.new() is depracated

This discussion is preserved as it was. New answers, comments, and votes are closed.