How to make that if so me o n e to u che s the ro o f the n i t g i v e s c o i n s? P l e a s e h e l p.
Scripts: (all in s e r v e r s c r i p t s e r v i c e) local DataStoreService = game:GetService("DataStoreService") local CoinsStore = DataStoreService:GetDataStore("CoinsStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder") --making leaderstats
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Coins = Instance.new("IntValue") --making coins
Coins.Name = "Coins"
Coins.Parent = leaderstats
local UserId = player.UserId
local data
local success, errormessage = pcall(function() --getting loaded data
data = CoinsStore:GetAsync(UserId)
end)
if success then
Coins.Value = data
end
end)
game.Players.PlayerRemoving:Connect(function(player) local UserId = player.UserId local data = player.leaderstats.Coins.Value
CoinsStore:SetAsync(UserId, data)
end)

9 comments
Workspace.Roof.Script:8: attempt to perform arithmetic (add) on Instance and number
player.leaderstats.Coins += 120
now error is
leaderstats is not a valid member of Player "Players.komanos212"
can you try player:WaitForChild("leaderstats").Coins += 120
now it's Workspace.Roof.Script:8: attempt to perform arithmetic (add) on Instance and number
you need to do .Value
i forgot to add that, my bad ;-;
player.leaderstats.Coins.Value += --whatever amount you want --gives coins