Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DSS = game:GetService("DataStoreService")
- local LB = DSS:GetDataStore("Leaderboards")
- game.ReplicatedStorage.RemoteEvents.Update.OnServerEvent:Connect(function(plr, Time, obby) -- Se detecta
- print("Detected!")
- print(Time)
- Time *= 10
- Time = math.floor(Time)
- Time = Time / 10
- print(Time)
- if(Time > 2) then
- print(obby)
- print(Time)
- if(obby == "OTO" and Time < 15) then else if(obby == "ETO" and Time < 9.5) then else if(obby == "EKO" and Time < 10.2) then else if(obby == "EWHO" and Time < 12) then else if(obby == "MTO" and Time < 14) then else if(obby == "MKO" and Time < 14.2) then else if(obby == "MWHO" and Time < 19) then else if(obby == "HTO" and Time < 14.5) then else if(obby == "HKO" and Time <16.5) then else if(obby == "HWHO" and Time < 18) then else
- if(game.ReplicatedStorage.Leaderboards[obby].Times.P5.Value >= Time or game.ReplicatedStorage.Leaderboards[obby].Times.P5.Value == 0) then -- Si es un record...
- local currentPos = 5
- local score = 0
- print(obby)
- for i,v in pairs(game.ReplicatedStorage.Leaderboards[obby].Times:GetChildren()) do -- Por cada posicion...
- print("Checking with "..i.." in "..obby)
- if v.Value >= Time then -- Si el valor de la posicion es mayor que el tiempo...
- if score == 0 then -- Si no se ha encontrado el record se actualiza
- print("Setting position as "..i)
- score = i
- end
- end
- end
- local otherScore = -1
- for i,v in pairs(game.ReplicatedStorage.Leaderboards[obby].Persons:GetChildren()) do -- Por cada posicion...
- if v.Value == plr.Name then
- otherScore = i
- end
- end
- local items = {
- Time1 = LB:GetAsync(obby)["Time1"],
- Time2 = LB:GetAsync(obby)["Time2"],
- Time3 = LB:GetAsync(obby)["Time3"],
- Time4 = LB:GetAsync(obby)["Time4"],
- Time5 = LB:GetAsync(obby)["Time5"],
- Person1 = LB:GetAsync(obby)["Person1"],
- Person2 = LB:GetAsync(obby)["Person2"],
- Person3 = LB:GetAsync(obby)["Person3"],
- Person4 = LB:GetAsync(obby)["Person4"],
- Person5 = LB:GetAsync(obby)["Person5"]
- }
- print(otherScore)
- if otherScore >= 1 then
- print("Has alr a score!")
- print(otherScore)
- print(score)
- if otherScore > score then
- print("Got better time!")
- local pos = otherScore
- while pos <= 5 do
- print("Chaning "..(pos + 1).." to new position "..pos)
- if pos < 5 then
- game.ReplicatedStorage.Leaderboards[obby].Times["P"..pos].Value = game.ReplicatedStorage.Leaderboards[obby].Times["P"..(pos + 1)].Value or 0-- Se actualizan los valores
- items["Time"..pos] = game.ReplicatedStorage.Leaderboards[obby].Times["P"..(pos + 1)].value or 0
- game.ReplicatedStorage.Leaderboards[obby].Persons["P"..pos].Value = game.ReplicatedStorage.Leaderboards[obby].Persons["P"..(pos + 1)].Value or "None"-- Se actualizan los valores
- items["Person"..pos] = game.ReplicatedStorage.Leaderboards[obby].Persons["P"..(pos + 1)].value or "None"
- else
- game.ReplicatedStorage.Leaderboards[obby].Times["P"..pos].Value = 0-- Se actualizan los valores
- items["Time"..pos] = 0
- game.ReplicatedStorage.Leaderboards[obby].Persons["P"..pos].Value = "None"-- Se actualizan los valores
- items["Person"..pos] = "None"
- end
- pos = pos + 1
- end
- local newPos = 5
- while newPos > score do -- Loop desde el ultimo hasta la nueva posicion
- print("Changing "..newPos)
- game.ReplicatedStorage.Leaderboards[obby].Times["P"..newPos].Value = game.ReplicatedStorage.Leaderboards[obby].Times["P"..(newPos - 1)].Value -- Se actualizan los valores
- items["Time"..newPos] = game.ReplicatedStorage.Leaderboards[obby].Times["P"..(newPos - 1)].value
- game.ReplicatedStorage.Leaderboards[obby].Persons["P"..newPos].Value = game.ReplicatedStorage.Leaderboards[obby].Persons["P"..(newPos - 1)].Value -- Se actualizan los valores
- items["Person"..newPos] = game.ReplicatedStorage.Leaderboards[obby].Persons["P"..(newPos - 1)].value
- newPos = newPos - 1
- end
- game.ReplicatedStorage.Leaderboards[obby].Times["P"..score].Value = Time
- items["Time"..score] = Time
- game.ReplicatedStorage.Leaderboards[obby].Persons["P"..score].Value = plr.Name
- items["Person"..score] = plr.Name
- end
- if otherScore == score then
- print("Same position :0")
- game.ReplicatedStorage.Leaderboards[obby].Times["P"..score].Value = Time
- items["Time"..score] = Time
- end
- end
- if otherScore == -1 then
- while currentPos > score do -- Loop desde el ultimo hasta la nueva posicion
- print("Changing "..currentPos)
- game.ReplicatedStorage.Leaderboards[obby].Times["P"..currentPos].Value = game.ReplicatedStorage.Leaderboards[obby].Times["P"..(currentPos - 1)].Value -- Se actualizan los valores
- items["Time"..currentPos] = game.ReplicatedStorage.Leaderboards[obby].Times["P"..(currentPos - 1)].value
- game.ReplicatedStorage.Leaderboards[obby].Persons["P"..currentPos].Value = game.ReplicatedStorage.Leaderboards[obby].Persons["P"..(currentPos - 1)].Value -- Se actualizan los valores
- items["Person"..currentPos] = game.ReplicatedStorage.Leaderboards[obby].Persons["P"..(currentPos - 1)].value
- currentPos = currentPos - 1
- end
- game.ReplicatedStorage.Leaderboards[obby].Times["P"..score].Value = Time
- items["Time"..score] = Time
- game.ReplicatedStorage.Leaderboards[obby].Persons["P"..score].Value = plr.Name
- items["Person"..score] = plr.Name
- end
- LB:SetAsync(obby, items)
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end)
Add Comment
Please, Sign In to add comment