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 : https://www.roblox.com/games/14917960...
Floppys Simulator Game: https://www.roblox.com/games/13963457...
FloppyFish Merch Store: https://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 : https://www.roblox.com/games/11301003...
Roblox Studio Tutorial
Roblox Studio
Studio Tutorials
Смотрите видео How to make a COIN SYSTEM | Roblox Studio Tutorial онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Itz_FloppyFish 23 Декабрь 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 37,389 раз и оно понравилось 980 людям.