So I watched a vid and copied all the script exact, besides name of money. I ran it and it didn't work can someone correct the script.
local dataStores = game:GetService("DataStoreService"):GetDataStore("BuckDataStore")
local playerLeft = 0
game.Players.PlayerAdded:Connect(function(player)
playerLeft = playerLeft + 1
local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
stats.Parent = player
local money = Instance.new("IntValue")
money.Name = "ObbyBucks<|>" -- Change "Money" to anything you want to name it like "Cash"
money.Value = 100 -- Change the value to how many you want when the player joins the game
money.Parent = stats
player.CharacterAdded:Connect(function(character)
character.Humanoid.Walkspeed = 16
character.Humanoid.Died:Connect(function()
if character.Humanoid and character.Humanoid:FindFirstChild('creator') then
game.ReplicatedStorage.Status.Value = tostring(character.Humanoid.creator.Value.." Killed "..player.Name)
end
if character:FindFirstChild('GameTag') then
character.GameTag:Destroy()
end
player:LoadCharacter()
end)
end)
local player_data
pcall(function()
player_data = dataStores:GetAsync(player.UserId.."-ObbyBucks<|>")
end)
if player_data ~= nil then
money.Value = player_data
else
money.Value = 100
end
end)
local bindableEvent = Instance.new("BindableEvent")
game.Players.PlayerRemoving:Connect(function(player)
pcall(function()
dataStores:SetAsync(player.UserId..'-ObbyBucks<|>',player.stats.money.Value)
print('Saved')
playerLeft = playerLeft - 1
bindableEvent:Fire()
end)
end)
game:BindToClose(function()
while playerLeft > 0 do
bindableEvent.Event:Wait()
end
end)
