Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

my game is not saving the data can anyone fix this i request u pls can anyone? [closed]

Asked by
Sartaz110 -17
5 years ago
Edited 5 years ago

local datastore = game:GetService("DataStoreService"):GetDataStore("BucksDatastore")

local defaultCash = 100

local playersLeft = 0

game.Players.PlayerAdded:Connect(function(player)

playersLeft = playersLeft + 1

local leaderstats = Instance.new("Folder")

leaderstats.Name = "leaderstats"

leaderstats.Parent = player

local bucks = Instance.new("IntValue")

bucks.Name = "Bucks"

bucks.Value = 0

bucks.Parent = leaderstats

player.CharacterAdded:connect(function(character)

character.Humanoid.WalkSpeed = 16

character.Humanoid.Died:Connect(function()

-- whenever somebody dies, the event will run

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)

-- Data Stores

local player_data

pcall(function()

player_data = datastore:GetAsync(player.UserID.."-Bucks")

end)

if player_data ~= nil then

-- Player has saved data , load it in

bucks.Value = player_data

else

-- New Player

bucks.Value = defaultCash

end

end)

local bindableEvant = Instance.new

game.Players.PlayerRemoving:Connect(function(player)

pcall(function()

datastore:SetAsync(player.UserID.."-Bucks",player.leaderstats.Bucks.Value)

print("Saved")

playersLeft = playersLeft - 1

bindableEvant:Fire()

end)

end)

game:BindToClose(function()

-- This will be triggered upon shut down

while playersLeft > 0 do

bindableEvant.Evant:Wait()

end

end)

0
No back information? This isnt a request site voidofdeathfire 148 — 5y
0
I can fix it if you want tho voidofdeathfire 148 — 5y
0
Welp, this isn't really a request you know starmaq 1290 — 5y
0
pls fix it :( Sartaz110 -17 — 5y

Closed as Not Constructive by User#24403

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?