#decimal value leaderstat
1 messages · Page 1 of 1 (latest)
This is the leaderstat script
local LeaderboardDataStore = DataStore:GetDataStore("LeaderboardDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Rarity = Instance.new("NumberValue", leaderstats)
Rarity.Name = "HighestRarity"
local Rerolls = Instance.new("NumberValue", leaderstats)
Rerolls.Name = "Rerolls"
local UserId = player.Name.." - "..player.UserId
local success, data = pcall(function()
return LeaderboardDataStore:GetAsync(UserId)
end)
if success and data then
Rarity.Value = data.Rarity or 0
Rerolls.Value = data.Rerolls or 0
else
Rarity.Value = 1
Rerolls.Value = 0
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local UserId = player.Name.." - "..player.UserId
local data = {
Rarity = player.leaderstats.HighestRarity.Value,
Rerolls = player.leaderstats.Rerolls.Value
}
local success, errormessage = pcall(function()
return LeaderboardDataStore:SetAsync(UserId, data)
end)
if not success then
warn("Failed to save data for "..player.Name.." - "..errormessage)
else
print("Successfully saved data for "..player.Name)
end
end)```
and pretty much
when i try to change the Rarity leaderstat to a decimal value like 0.1 trough remote event on server it rounds it to 1
my goal it to make it actually 0.1
as you can see i use numbervalue and i am pretty sure they should support decimals right
Show the local script for displaying the numbers
he uses leaderstats soo
there prob isnt one
oh wait theres remote part we not seeing (or im blind)
where do u fire the remote
well i fire it in a local script but the numbers are in server script
can you show the scripts?
the one u showed is just loading from db
yeah
SecretValue.Changed:Connect(function()
if SecretValue.Value <= 0 then
print("Error")
elseif SecretValue.Value <= 285714 then
ShowRoll:FireClient(Player, "Legacy")
UnlockIndex:FireClient(Player, "Legacy")
if RarityLeaderstat.Value <= 3500 then
RarityLeaderstat.Value = 0.35
end
elseif SecretValue.Value <= 769230 then
ShowRoll:FireClient(Player, "Positive")
UnlockIndex:FireClient(Player, "Positive")
if RarityLeaderstat.Value <= 1300 then
RarityLeaderstat.Value = 0.13
end
elseif SecretValue.Value <= 1111111 then
ShowRoll:FireClient(Player, "Effect")
UnlockIndex:FireClient(Player, "Effect")
if RarityLeaderstat.Value <= 900 then
RarityLeaderstat.Value = 0.09
end
elseif SecretValue.Value <= 9900990 then
ShowRoll:FireClient(Player, "Nothing")
UnlockIndex:FireClient(Player, "Nothing")
if RarityLeaderstat.Value <= 100 then
RarityLeaderstat.Value = 0.01
end
elseif SecretValue.Value > 1010101 then
return
end
end)
end)```
wait
yeah this
is the serverscript
ReplicatedStorage.Roll:FireServer(Player)
end)```
this is the local script
that fires it
i dont really think the problem is in these script tho
it changes it normally
just not into a decimall
when it should change to 0.01 it changes to 1
and i need it to ofc be 0.01
@candid socket
also just sayin the whole thing is like much much longer so i only posted th part where the leaderstats change
on leaderstats?
im really lost about this code
where did you define rarityleaderstat?
the leaderstat changes
inside player added or smth?
Where exacly is RarityLeaderstat defined
because the roll function sends the player
local leaderstats = Player:WaitForChild("leaderstats")
local RarityLeaderstat = leaderstats.HighestRarity
local RerollsLeaderstat = leaderstats.Rerolls
right under it
or its instantly turning 0.01 to 1
so you see it turn to 0.01 then turn to 1?
how fast do u roll
after joining
just checking if maybe data is failing to load so it sets to 1
(datasaving)
wait
unless im looking at wrong leaderstat
could you first add more prints?
add some print to the else here
just to be sure
and when you roll you have a chance to change your leaderstat to 0.01
its not about loading
and try to print here
maybe print rarityleaderstat.Value difrectly after changing it
i dont think you understand
it definetly isnt supposed to be rounding
you can fire roll any time
so i feel like other script is doing that
and when you roll it can set your leaderstat to 0.01 which ofc it will make it 1
also even if it would round im pretty sure it will round down to 0
i think it works wait
this is madness
i think i found something else as a probelm
anyway numbervalue shows 2 decimal places for values <1000
for some reason highest leaderstat doesnt save
local LeaderboardDataStore = DataStore:GetDataStore("LeaderboardDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Highest = Instance.new("NumberValue", leaderstats)
Highest.Name = "Highest"
local Rerolls = Instance.new("NumberValue", leaderstats)
Rerolls.Name = "Rerolls"
local UserId = player.Name.." - "..player.UserId
local success, data = pcall(function()
return LeaderboardDataStore:GetAsync(UserId)
end)
if success and data then
Highest.Value = data.Highest or 0
Rerolls.Value = data.Rerolls or 0
else
Highest.Value = 1
Rerolls.Value = 0
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local UserId = player.Name.." - "..player.UserId
local data = {
Rarity = player.leaderstats.Highest.Value,
Rerolls = player.leaderstats.Rerolls.Value
}
local success, errormessage = pcall(function()
return LeaderboardDataStore:SetAsync(UserId, data)
end)
if not success then
warn("Failed to save data for "..player.Name.." - "..errormessage)
else
print("Successfully saved data for "..player.Name)
end
end)```
the highest stat doesnt load
it says saved data
but when loading it doesnt load the highest data
but does rerolls
wait
ok
yeah im dumb
you never changed it did u
well nwm
/on client
what
probably changing it on client ya
what client
no if u loook at line 32 i forgor to rename rarity to highest
that it
the whole problem
one more thing guys
if i do if RarityLeaderstat.Value <= 100 and not 0.35 or 0.13 or 0.09 then
does it do the function only if the value is below 100 and isnt any of the other numbers mentioned? just to confirm it works like i think
@candid socket
@keen oyster
nwm
** You are now Level 15! **