How to make a COIN SYSTEM | Roblox Studio Tutorial
Вставка
- Опубліковано 22 гру 2023
- In todays video I show you how to make an entire coin system in Roblox Studio! This type of system can be used in multiple ways, Either simply for coins or any type of system which includes the players leaderstat value increasing! In this tutorial we go over the datasaving part aswell as 2 ways on how you can make a coin which gives the player the currency work. if you did want this type of feature in your game make sure to watch to the end of the video to find out how!
I really enjoy making these videos for you all so I hope you enjoy them just as much as I do!
Have a lovely rest of your day!
Script 1 (DataSavingScript)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local DatastoreService = game:GetService("DataStoreService")
local Data = DatastoreService:GetDataStore("2")
local sessionData = {}
function PlayerAdded(player)
local coins = Instance.new("NumberValue")
coins.Name = "Coins" -- Change Coins to whatever your currency is called.
coins.Parent = player
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
coins.Parent = leaderstats
local success, playerData = pcall(function()
return Data:GetAsync(player.UserId)
end)
if success then
print("Data loaded: " .. player.Name)
if not playerData then
print("New player, giving default data")
playerData = {
["Coins"] = 0, -- Change Coins to whatever your currency is called.
}
end
sessionData[player.UserId] = playerData
else
warn("Couldn't load data: " .. player.Name)
player:Kick("Couldn't load your data, rejoin")
end
coins.Value = sessionData[player.UserId].Coins -- Change Coins to whatever your currency is
coins:GetPropertyChangedSignal("Value"):Connect(function()
sessionData[player.UserId].Coins = coins.Value -- Change Coins to whatever your currency is
end)
end
Players.PlayerAdded:Connect(PlayerAdded)
function PlayerLeaving(player)
if sessionData[player.UserId] then
local success, errorMsg = pcall(function()
Data:SetAsync(player.UserId, sessionData[player.UserId])
end)
if success then
print("Data saved: " .. player.Name)
else
warn("Can't save: " .. player.Name)
end
end
end
Players.PlayerRemoving:Connect(PlayerLeaving)
function ServerShutdown()
if RunService:IsStudio() then
return
end
for _, player in ipairs(Players:GetPlayers()) do
task.spawn(function()
PlayerLeaving(player)
end)
end
end
game:BindToClose(ServerShutdown)
-----------------------
Script 2, System one (Part doesnt move) :
local CoinsAdded = 1 -- Change the number to adjust how much you want the player to receive each time
local RespawnTime = 5 -- Change the number to adjust how often you want the coin to respawn
local Debounce = false
script.Parent.Touched:Connect(function(touched)
if Debounce then
return
end
local Player = game.Players:GetPlayerFromCharacter(touched.Parent)
if Player then
local Leaderstats = Player:FindFirstChild("leaderstats")
local Coins = Leaderstats and Leaderstats:FindFirstChild("Coins") -- Change coins to whatever your currency is called which you want the values to add onto
if Coins then
Debounce = true
Coins.Value = Coins.Value + CoinsAdded
script.Parent.Transparency = 1
wait(RespawnTime)
script.Parent.Transparency = 0
Debounce = false
end
end
end)
-----------------------
Script 3, System 2 (With coin random spawning) :
Can be found in the comments! Because ive reached the word limit for this description!
-- Made with love by Floppy
---------------------
If you are a bit confused what to do, Feel free to create a ticket in my discord server and we can help you out!
NEW! Floppys Obby Game : www.roblox.com/games/14917960...
Floppys Simulator Game: www.roblox.com/games/13963457...
FloppyFish Merch Store: itz-floppyfish.creator-spring...
If you would like to support me even more, Super Thanks and becoming a Member is also another way to show your appreciation!
🌟 Floppys Discord Server: / discord
🌟 Floppys Roblox Game : www.roblox.com/games/11301003...
Roblox Studio Tutorial
Roblox Studio
Studio Tutorials - Ігри
Script 3:
local CoinsAdded = 1 -- Change the number to adjust how much you want the player to receive each time
local RespawnTime = 2.5 -- Change the number to adjust how often you want the coin to respawn
local RespawnPart = game.Workspace.RespawnPart -- Change "RespawnPart" to whatever your part is called where the parts will spawn
local CoinSize = script.Parent.Size -- Store the original size of the coin
local Debounce = false
local function respawnCoin()
local RespawnPartSize = RespawnPart.Size
local RandomPosition = Vector3.new(
math.random(-RespawnPartSize.X/2, RespawnPartSize.X/2),
RespawnPart.CFrame.Position.Y + RespawnPartSize.Y / 2 + CoinSize.Y / 2,
math.random(-RespawnPartSize.Z/2, RespawnPartSize.Z/2)
)
script.Parent.Position = RespawnPart.CFrame.Position + RandomPosition
script.Parent.CanTouch = true
script.Parent.Transparency = 0
Debounce = false
end
respawnCoin()
script.Parent.Touched:Connect(function(hit)
local Humanoid = hit.Parent
if Debounce then
return
end
local Player = game.Players:GetPlayerFromCharacter(Humanoid)
if Player then
local Leaderstats = Player:FindFirstChild("leaderstats")
local Coins = Leaderstats and Leaderstats:FindFirstChild("Coins")
if Coins then
Debounce = true
Coins.Value = Coins.Value + CoinsAdded
script.Parent.CanTouch = false
script.Parent.Transparency = 1
wait(RespawnTime)
respawnCoin()
end
end
end)
hey can u make a tutorial about making a shop u can bu multiplier from ? u can buy the multiplier With coin or in game currency.
Hey Floppy, Can u make a video on Buying houses with a Cash leaderstat, Also, I am making a game and was wondering if u wanted a car of ur choice?
I need this too! I'm having a hella time trying to get this working.@@GamingRereplanet
Thank you so very much! Please make an Upgrade system tutorial for us for CoinBoost upgrades i'm getting so much conflicting info on this.
Hi i really want to make coins but i want to make it so when you collect it you can buy something in game with the coins with that could you maybe help me out?
Thank you for making this tutorial! This was very informative and helped me make progress in creating my first game.
omg I Finally created a coin system thank you so much I will subscribe!
you are so underrated! Amazing Video!
Thank you Floppy for everything you have done i have been using this for my game thank you!
Thank you, this really helped with my simulator game!
I FIGURED IT OUT BABY LETS GOOO
I was looking for this
I will subscribe thank you so much!!!!
I have used this multiple times in my game!
I had to rewatch the video a few times to get it right.
1st off - I created a 3rd script inside the AreaPart (idiotically)
And not changing the Coin script🤦♂
2nd error - I didn't hear any "You need to Enable API in Studio for DataStoreService"🤷♂
I only saw why it kept kicking me out - bcoz of the API problem
Otherwise it works nicely now 👍
i made the 2nd mistake, thanks
I needed this for my cat sim 1 game thank you! And Merry Christmas 🎁🎄
Edit! HE GAVE MY COMMENT A HEART ❤️💖
Hey floppy! I See you are making lots of coins tutorials, so can you please make a tutorial on how to make a tool shop that you can purchase items with coins!
I hope he makes a video soon that ties in the currency system he made previously to an in game tool shop.
Hey floppy can you make a tutorial on how to make a badges collected gui. Like it shows how many badges the player has collected out of all the badges there are to be collected in the game. If you do this thanks ❤😊
Hey I've been looking for a tutorial on how to make a currency and shop system but there's no tutorials for shops that i understand so can you please make a tutorial for a working shop that saves when you leave and rejoin the game and also when you buy an item with coins and you dont have enough, instead of going into minus amount it says you don't have enough to buy the item - these are my most 2 common encounters that makes the shop not work, so i'd be so relieved if you could make a shop system that works along with the coins you made in this video
Ikr i cant find nutin
please make a tutorial on how to sell items to NPCs and how to make daily rewards. I will be very grateful
Listen to this guy this is a great idea!!!
bro please we would like to watch your videos with u.
i mean with this with your facecam please! :)
Crazy tutorials TYSM!
The webcam would get in the way of what's happening, I think. I prefer it without the webcam for the tutorials, but we all have different opinions :)
@@rostopi-scripting1304 👍 right all have their different opinions, i left roblox now!
Goodluck developing your skills.
@@OreNinja_ , thanks.
I have made the coins now but could you do a video on how to make a shop that you can use the coins in.
You could also do the tutorial to spend those coins in a store
thats so easy bro i learned lua yesterday and i can do that without a tutorial
@@happyfishgaming69 Then why dont you share it to us huh?
fr@@SunBerryDev
thats the most easy thing to do just grow up buddy@@SunBerryDev
Hey this was useful but can you make a tutorial on how to make a shop GUI for these coins instead of robux I cant seem to find one
This was a lie, it turns out I was wrong. And thank you for the tutorias😅😅
can you make a video on how to make a gui that spawns any model in roblox studio?
Hey Floppy could you make a tutorial to spend the coins on trails and pets ?
AYO I GAVE YOU THIS IDEA ON DISCORD
Hi floppy
Can you please make a Combat system video?
Can you make a video on how to buy a block door with a frame that I asked you if you want to buy, and with auto-save? please. By money I mean in-game coins.
Hey floppy, i was wondering how u could make it so u can buy things with the coins
i get issue all done like u said but while team test the coin is floating above means i will be not there in its original place
Will you be going live today I really want you to play my game
Can you show how to do super powers
It dose't work! because when I join The game, then it's just a sign thats saying ''could not load your data, please rejoin'' and I have rejoind like a hundred times!
you have to team test. or play the actual game
i had the same problom
alr thx but can u do an tutorial how to spend these coins in a dialogchoiche like u start a dialog and the rig says [welcome to mcdoolands what u wanna order] and u click burger and then rig says [one dollars pls] and then you will make a dialog choiche that says *Pays* but i want that when i clikc the *Pays* dialogchoiche i want one coin to get out of my leaderboard pls make this i really need to my game it was alot of stores
Hey can you make a video how to make a wall cost coin i really need to know for a game im making
Hello Floppy, i join game but the part(coin) was lost from a map how do i fix it.
ik how to do it but the problem is i don't know how to make it random spawn
I cant find the can collide button on the model i made on blender any solutions?
Hello Floppy. I am back on another account and with another name!
how do i link my gamepass to it cause i want to have like a "2x coins" gamepass but i dont know how to implement it
Hi Floppy, this script is awesome, thankyou! However, I notice that it only works if the coin is a single Part, but not a Model. Pls HELP! 😲
Can you make a video on how to give those coins different values? (Like a gold coin gets you 10 coins, and a silver one gets you 1.)
just duplicate the coins and change the value in the script
that is so simple I don't know how you need a tutorial for that.
@@triploonic4042 I’m not that good at scripting lol
@@bananabreadboi797 all you need to do is change a number 💀
kill boss for badge , how to make this?
Can somebody please help me. I used the script in the video for the saving leaderstats and the coin script (number 1 and 2) but for some reason when I rejoin the game it defaults it to one coin but I collected 5 before I stopped and tried again. does anybody know why that is happening?
Is it necessary for the folder to be named leaderstats?
Yes.
Can someone pls help? When i delete my old coin skript and insert the new one the coin stops working...
hello floppy can you help me?
about roblox coding?
If anyone can help me i want to give the player when the player touches the coin from 1 - 5 coins but it kinda does work alltho when the math.random picks a number between 1 - 5 it always picks that number that it picked and not a random number between 1 - 5
Why does the first script stop my player from moving?!
Whenever i start the game the coins spawn under the area
i dont know why but when i enter the coin is not in the game
why is it spaming me with you were kickted frome this exprince
could not load data please rejoin
why is my game just gone
what about multipliers
Early
pro how do make sowrd coins pls
nvm i fixed it
floppy mycharacter wont move when i copy scriot 1
idk why but if i don't have can collide on they invisible
nvm my problem was the object needed to be anchored
hey when i join it says i was kicked
It says that for me to it says that I have no data or something
you have to team test@@Reditofworld
When I try and test my game, bc of the dataservice script, I get kicked
Same
enable api
i did @@flox348
dont play test
it dont work
i cant move after the first script
i see only sky
anchor the map.
when I disable cancolline the block dissapears
Fr
anchor it
@@MrPeeps1122 what do you mean?
@@Monty-2324 go to the objects u want as the coin and anchor it, it’s in like the middle of ur screen i guess
@@MrPeeps1122 i actually found another way to do it and i stoped making that game
Pls can someone help me to develop my game
Hi floppy