Hello,
I'm making a "Stay Alive and Steal Time" game on ROBLOX, and I believe I messed up something with the "ends". Could I get some help correcting whatever error there is? Here is the script:
local DataStoreService = game:GetService("DataStoreService")
local Datastore = DataStoreService:GetDataStore("TimeStatistics")
game.Players.PlayerAdded:Connect(function(Player)
local leaderstats_folder = Instance.new("Folder", Player)
leaderstats_folder.Name = "leaderstats"
local Top_Time = Instance.new("IntValue", leaderstats_folder)
Top_Time.Name = "TopTime"
Top_Time.Value = 0
local Time_Alive = Instance.new("IntValue", leaderstats_folder)
Time_Alive.Name = "TimeAlive"
Time_Alive.Value = 0
local Kills = Instance.new("IntValue", leaderstats_folder)
Kills.Name = "Kills"
Kills.Value = 0
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:FindFirstChild("Humanoid")
humanoid.Died:Connect(function(died)
local tag = humanoid:FindFirstChild("creator")
local killer = tag.Value
if tag and killer then
killer.leaderstats:FindFirstChild("Kills").Value = killer.leaderstats:FindFirstChild("Kills").Value + 1
local key = Player.UserId .. "-TimeStatistics"
local storeditems = {0,0}
local Succes, ErrorMessage = pcall(function()
storeditems = Datastore:GetAsync(key)
end)
if Succes then
print("data successfully recieved for " .. Player.UserId)
if storeditems then
Top_Time.Value = storeditems[1]
Time_Alive.Value = storeditems[2]
Kills.Value = storeditems[3]
else
local items_to_store = {Top_Time.Value ,Time_Alive.Value, Kills.Value}
Datastore:SetAsync(key, items_to_store)
end
else
print("something went wrong while loading data for " .. Player.UserId)
end
end
end)
end)
end)
end)

3 comments
Adding on to this, I was trying to combine two scripts. That's why I believe that I messed up the ends.
Could you elaborate? what comes out in output when you try to run this?
I FIGURED IT OUT, SORRY TO BOTHER!!!