Project 369: Collecting Coins

4. Make CreateCoin Function

Create a function called "CreateCoin" that will hold the code that creates a single coin.
Starting point file for this challenge

Steps

1. Create a function called 'CreateCoin'

Create a function called 'CreateCoin' that does not have any parameters.
function CreateCoin()

2. Add an 'end' to the function

Hit return on your keyboard after the parentheses to and an 'end' statement to your function.
function CreateCoin() end

3. Create local variable 'coin'

Inside the function, create a local variable called 'coin'.
local coin

4. Make 'coin' a new instance of part

Set 'coin' to a new instance of a part. At this point it’s just a blank, generic part.
local coin = Instance.new("Part", workspace)

5. Set the coin at a random position on the ground

Set the coin’s position to a random x and z position, but keep the y position at 0. This keeps the coin on the ground.
coin.Position = Vector3.new(math.random(100), 0, math.random(100))