Why do leaderstats round to the nearest whole number?

The script below is a leaderstats script that has 3 stats. Kills, Deaths, and K/D. My goal is to make the K/D value display the ratio, so if you have 1 kill 2 deaths it is 0.5. Right now when you have 1 kill 2 deaths, it rounds the ratio to 1. How would I stop it from rounding?


game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder")
	local Kills = Instance.new("IntValue")
	local Deaths = Instance.new("IntValue")
	local Ratio = Instance.new("IntValue")
	leaderstats.Name = "leaderstats"
	Kills.Name = "Kills"
	Deaths.Name = "Deaths"
	Ratio.Name = "K/D"
	Kills.Value = 0
	Deaths.Value = 0
	Ratio.Value = 0
	Kills.Parent = leaderstats
	Deaths.Parent = leaderstats
	Ratio.Parent = leaderstats
	leaderstats.Parent = plr
	while true do
		wait(.1)
		if Deaths.Value ~= 0 then
			Ratio.Value = Kills.Value/Deaths.Value
		else
			Ratio.Value = Kills.Value
		end
	end
end)

An integer is a whole number so you should convert your int value into a number value.

local Ratio = Instance.new("NumberValue")

You should also use :GetPropertyChangedSignal instead of using a while loop to find out whether the value has changed

Try using NumberValues instead of IntValues

Because IntValue doesn’t accepts non-whole numbers I think so.

1 Like