How to make a COLLECTABLE coin in Roblox Studio!

This is my second tutorial! In this tutorial, we will make a collectable coin!

Step 1: Make a leaderstats script inside ServerScriptService and put the code needed.

Step 2: Add a script inside the leaderstats script and do some code to save the leaderstats.

IMPORTANT: TO DO STEPS 1 AND 2, MAKE SURE TO GO TO THE TUTORIAL: How to make a SAVING leaderstats in Roblox Studio!

THE TUTORIAL ABOVE CAN REALLY HELP YOU FOREVER!

Step 3: Add a coin shaped PART somewhere in the Workspace. (tip: insert a cylinder and scale it until it looks right.)

Step 4: Add a script inside of the part(make sure to name the part “coin”.

Step 5: Make a function in the script!

script.Parent.Touched:Connect(function(hit)

end)

Step 6: Add the following to the function to detect the player who touched the coin.

if hit then
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
end

Step 7: Add the following code to the “if hit then” statement to increase the amount of coins the player gets.

plr:WaitForChild("leaderstats"):WaitForChild("Coins").Value += 1 -- change "1" to how much you want to give the player when touched

Step 8: After the line of code on Step 7, add the following to:

Destroy the Coin!

script.Parent:Destroy()

OR

Make the coin respawn after a period of time. Note that the coin will spawn in the same location. If you want a random location, use the code above with another tutorial in the future!

local coin = script.Parent
coin.Parent = game.ReplicatedStorage
wait(1) -- Cooldown
coin.Parent = game.Workspace

And that’s it! If you want to change the coin, you can! Here are some big changes that can work!

  • Changing the color(to the theme if you want)
  • Changing the Name(will not affect gameplay)
  • Changing the amount the coin gives(you can make an upgrade if you can to add coins by another amount!)
  • Changing the cooldown(you can make another upgrade for it)
  • Making an area where the coins can drop anywhere in the area(future tutorial?) (tip: move the coin to ReplicatedStorage and clone it and place it in the area)
  • There are much more changes to make! You can use this to make a simulator game, tycoon game, and even change the coin to weapons to fight(fighting game)!
  • Change the coin to an inventory item!
  • (and much more!)

Here’s the finished script of the coin(it’s very easy!):

script.Parent.Touched:Connect(function(hit)
	if hit then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		plr:WaitForChild("leaderstats"):WaitForChild("Coins").Value += 1-- change "1" to how much you want to give the player when touched
		local coin = script.Parent
		coin.Parent = game.ReplicatedStorage
		wait(1) -- Cooldown
		coin.Parent = game.Workspace
	end
end)
4 Likes