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
  • Ігри

КОМЕНТАРІ • 104

  • @Itz_FloppyFish
    @Itz_FloppyFish  5 місяців тому +15

    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)

    • @GamingRereplanet
      @GamingRereplanet 5 місяців тому

      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.

    • @Jomquqviusjamaljr
      @Jomquqviusjamaljr 5 місяців тому

      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?

    • @ShadowSerpentx
      @ShadowSerpentx 3 місяці тому

      I need this too! I'm having a hella time trying to get this working.@@GamingRereplanet

    • @ShadowSerpentx
      @ShadowSerpentx 3 місяці тому

      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.

    • @Pro_Bloxxer
      @Pro_Bloxxer Місяць тому

      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?

  • @grimm_bot
    @grimm_bot 2 місяці тому +2

    Thank you for making this tutorial! This was very informative and helped me make progress in creating my first game.

  • @ladypachuko717
    @ladypachuko717 5 місяців тому +3

    omg I Finally created a coin system thank you so much I will subscribe!

  • @RobloxOdd
    @RobloxOdd Місяць тому

    you are so underrated! Amazing Video!

  • @The_Inevitable2
    @The_Inevitable2 3 місяці тому

    Thank you Floppy for everything you have done i have been using this for my game thank you!

  • @rostopi-scripting1304
    @rostopi-scripting1304 Місяць тому

    Thank you, this really helped with my simulator game!

  • @JACOBexclamationmark
    @JACOBexclamationmark 3 місяці тому

    I FIGURED IT OUT BABY LETS GOOO

  • @electricpeagaming
    @electricpeagaming 12 днів тому

    I was looking for this

  • @DaCannySweat
    @DaCannySweat 2 місяці тому

    I will subscribe thank you so much!!!!

  • @SetheunVlogsTM
    @SetheunVlogsTM 3 місяці тому

    I have used this multiple times in my game!

  • @TQNY
    @TQNY 5 місяців тому +5

    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 👍

    • @flox348
      @flox348 4 місяці тому

      i made the 2nd mistake, thanks

  • @yo_arcade27
    @yo_arcade27 5 місяців тому +1

    I needed this for my cat sim 1 game thank you! And Merry Christmas 🎁🎄

    • @yo_arcade27
      @yo_arcade27 5 місяців тому +1

      Edit! HE GAVE MY COMMENT A HEART ❤️💖

  • @MGMattGZ
    @MGMattGZ 5 місяців тому +5

    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!

    • @FUBUOF
      @FUBUOF 10 днів тому

      I hope he makes a video soon that ties in the currency system he made previously to an in game tool shop.

  • @Marvo_YT
    @Marvo_YT 5 місяців тому +2

    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 ❤😊

  • @RTBHTBH
    @RTBHTBH 5 місяців тому +4

    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

    • @itzGPYT
      @itzGPYT 5 місяців тому +1

      Ikr i cant find nutin

  • @FOLLOWEEK
    @FOLLOWEEK 5 місяців тому +4

    please make a tutorial on how to sell items to NPCs and how to make daily rewards. I will be very grateful

    • @MemingDog
      @MemingDog 5 місяців тому

      Listen to this guy this is a great idea!!!

  • @OreNinja_
    @OreNinja_ 5 місяців тому

    bro please we would like to watch your videos with u.
    i mean with this with your facecam please! :)
    Crazy tutorials TYSM!

    • @rostopi-scripting1304
      @rostopi-scripting1304 Місяць тому

      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 :)

    • @OreNinja_
      @OreNinja_ Місяць тому +1

      @@rostopi-scripting1304 👍 right all have their different opinions, i left roblox now!
      Goodluck developing your skills.

    • @unstoppable2180
      @unstoppable2180 Місяць тому

      @@OreNinja_ , thanks.

  • @Coder-1256-GAMING
    @Coder-1256-GAMING 2 місяці тому +1

    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.

  • @derekcoronagomez151
    @derekcoronagomez151 5 місяців тому +5

    You could also do the tutorial to spend those coins in a store

    • @happyfishgaming69
      @happyfishgaming69 5 місяців тому +1

      thats so easy bro i learned lua yesterday and i can do that without a tutorial

    • @SunBerryDev
      @SunBerryDev 4 місяці тому +2

      @@happyfishgaming69 Then why dont you share it to us huh?

    • @TheRealPaintist
      @TheRealPaintist 4 місяці тому

      fr@@SunBerryDev

    • @NotBuba
      @NotBuba Місяць тому

      thats the most easy thing to do just grow up buddy​@@SunBerryDev

  • @guest8650
    @guest8650 2 місяці тому +1

    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

  • @khairu13
    @khairu13 Місяць тому

    This was a lie, it turns out I was wrong. And thank you for the tutorias😅😅

  • @DraggyBloxYT
    @DraggyBloxYT 25 днів тому +2

    can you make a video on how to make a gui that spawns any model in roblox studio?

  • @user-yd4pc8nn2c
    @user-yd4pc8nn2c 5 місяців тому +1

    Hey Floppy could you make a tutorial to spend the coins on trails and pets ?

  • @therealnovaaX
    @therealnovaaX 5 місяців тому

    AYO I GAVE YOU THIS IDEA ON DISCORD

  • @XxelitezYT
    @XxelitezYT 5 місяців тому +1

    Hi floppy

  • @TPVT
    @TPVT 3 місяці тому +1

    Can you please make a Combat system video?

  • @Onn-ng6ih
    @Onn-ng6ih 5 місяців тому

    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.

  • @ICEcoldddddd
    @ICEcoldddddd 3 дні тому +1

    Hey floppy, i was wondering how u could make it so u can buy things with the coins

  • @_cursed__lyrics_
    @_cursed__lyrics_ 3 місяці тому

    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

  • @Marvo_YT
    @Marvo_YT 5 місяців тому

    Will you be going live today I really want you to play my game

  • @MustacheShrek
    @MustacheShrek 5 місяців тому +1

    Can you show how to do super powers

  • @Tha_Burgir
    @Tha_Burgir 4 місяці тому +1

    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!

    • @pick03622
      @pick03622 4 місяці тому

      you have to team test. or play the actual game
      i had the same problom

  • @LeoMonkeyy
    @LeoMonkeyy 5 місяців тому

    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

  • @Real_Yandeloskijaja
    @Real_Yandeloskijaja 5 місяців тому

    Hey can you make a video how to make a wall cost coin i really need to know for a game im making

  • @whaleo8298
    @whaleo8298 4 місяці тому

    Hello Floppy, i join game but the part(coin) was lost from a map how do i fix it.

  • @Plixy1
    @Plixy1 5 місяців тому +1

    ik how to do it but the problem is i don't know how to make it random spawn

  • @noobiexd864
    @noobiexd864 3 місяці тому

    I cant find the can collide button on the model i made on blender any solutions?

  • @ArlxGamlng
    @ArlxGamlng 5 місяців тому +6

    Hello Floppy. I am back on another account and with another name!

  • @Vexyxzc
    @Vexyxzc Місяць тому

    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

  • @popquizzers
    @popquizzers Місяць тому

    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! 😲

  • @bananabreadboi797
    @bananabreadboi797 4 місяці тому

    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.)

    • @Pr0ctal
      @Pr0ctal 3 місяці тому

      just duplicate the coins and change the value in the script

    • @triploonic4042
      @triploonic4042 3 місяці тому

      that is so simple I don't know how you need a tutorial for that.

    • @bananabreadboi797
      @bananabreadboi797 3 місяці тому

      @@triploonic4042 I’m not that good at scripting lol

    • @triploonic4042
      @triploonic4042 3 місяці тому

      @@bananabreadboi797 all you need to do is change a number 💀

  • @Wendelcezar27
    @Wendelcezar27 5 місяців тому +1

    kill boss for badge , how to make this?

  • @Jandmungey
    @Jandmungey 4 місяці тому

    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?

  • @lorenplays3548
    @lorenplays3548 4 місяці тому

    Is it necessary for the folder to be named leaderstats?

  • @Nutzername_
    @Nutzername_ 5 місяців тому

    Can someone pls help? When i delete my old coin skript and insert the new one the coin stops working...

  • @CyanWaffles01
    @CyanWaffles01 5 місяців тому

    hello floppy can you help me?
    about roblox coding?

  • @JACOBexclamationmark
    @JACOBexclamationmark 3 місяці тому

    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

  • @ArtyMcFreak
    @ArtyMcFreak Місяць тому

    Why does the first script stop my player from moving?!

  • @PartyCarLAX
    @PartyCarLAX 5 місяців тому

    Whenever i start the game the coins spawn under the area

  • @Pixelpionner99
    @Pixelpionner99 18 годин тому

    i dont know why but when i enter the coin is not in the game

  • @pick03622
    @pick03622 4 місяці тому

    why is it spaming me with you were kickted frome this exprince
    could not load data please rejoin

  • @AQUArblx-fi2ol
    @AQUArblx-fi2ol 3 місяці тому +1

    why is my game just gone

  • @Idek_Name
    @Idek_Name 2 місяці тому

    what about multipliers

  • @Itz_Plutonium
    @Itz_Plutonium 5 місяців тому +1

    Early

  • @TPS997
    @TPS997 5 місяців тому

    pro how do make sowrd coins pls

  • @pick03622
    @pick03622 4 місяці тому

    nvm i fixed it

  • @user-jy7tu9ne2u
    @user-jy7tu9ne2u 15 днів тому

    floppy mycharacter wont move when i copy scriot 1

  • @proedevgaming
    @proedevgaming 9 днів тому

    idk why but if i don't have can collide on they invisible

    • @proedevgaming
      @proedevgaming 9 днів тому

      nvm my problem was the object needed to be anchored

  • @monkyboyi
    @monkyboyi 4 місяці тому +1

    hey when i join it says i was kicked

    • @Reditofworld
      @Reditofworld 4 місяці тому

      It says that for me to it says that I have no data or something

    • @pick03622
      @pick03622 4 місяці тому

      you have to team test@@Reditofworld

  • @Giltom09
    @Giltom09 5 місяців тому

    When I try and test my game, bc of the dataservice script, I get kicked

  • @CyclosVideos
    @CyclosVideos 17 днів тому

    i cant move after the first script

  • @AQUArblx-fi2ol
    @AQUArblx-fi2ol 3 місяці тому

    i see only sky

    • @Pr0ctal
      @Pr0ctal 3 місяці тому

      anchor the map.

  • @Monty-2324
    @Monty-2324 2 місяці тому

    when I disable cancolline the block dissapears

    • @spiralcub6277
      @spiralcub6277 Місяць тому +1

      Fr

    • @MrPeeps1122
      @MrPeeps1122 3 дні тому

      anchor it

    • @Monty-2324
      @Monty-2324 3 дні тому

      @@MrPeeps1122 what do you mean?

    • @MrPeeps1122
      @MrPeeps1122 2 дні тому

      @@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

    • @Monty-2324
      @Monty-2324 2 дні тому

      @@MrPeeps1122 i actually found another way to do it and i stoped making that game

  • @ElectroPlayzGames
    @ElectroPlayzGames 5 місяців тому

    Pls can someone help me to develop my game

  • @Rob3rt_YT
    @Rob3rt_YT 5 місяців тому +1

    Hi floppy