In todays video I show you how to make a Part or a Item give you currency (Cash or Coins) when the item is touched, this script includes a data store, meaning if a player leaves the game the data saves and when they rejoin they will have the same amount of currency before they left. I Hope you enjoyed the video, Have a lovely rest of your day!
If you are a bit confused what to do, Feel free to message me on Discord and Ill help you out!
🌟 Floppys Discord Server: [ Ссылка ]
Script 1 (Leaderstats Script) :
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Coin = Instance.new("IntValue")
Coin.Name = "Coins" -- Change this to what you want the leaderstat name to be
Coin.Value = 0
Coin.Parent = leaderstats
end)
Script 2 (GUI local Script) :
local CoinsLabel = script.Parent
local function onCoinsChanged(newValue)
CoinsLabel.Text = "Coins: " .. tostring(newValue) -- Change "Coins" to whatever you want your currency to be called
end
local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local Coins = leaderstats:WaitForChild("Coins")
onCoinsChanged(Coins.Value)
Coins.Changed:Connect(function(newValue)
onCoinsChanged(newValue)
end)
🌟 Floppys Roblox Game : [ Ссылка ]...
Roblox Studio Tutorial
Roblox Studio
Studio Tutorials
![](https://i.ytimg.com/vi/RJCJUVG4ONo/maxresdefault.jpg)