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

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

Asked by 4 years ago

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

0
kms NIMI5Q -2 — 4y
0
I'm sorry dude, there is not much to work with here. Please try to read some scripting tutorials first. sleazel 1287 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

"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)
0
the second argument for instance.new() is depracated Fad99 286 — 4y
Ad

Answer this question