Leaderstat giver not working

Hello, I have this code inside of a button in a GUI.

local rs = game:GetService("ReplicatedStorage")
local C = rs:WaitForChild("Client"):WaitForChild("Connection")
auto = false
if auto == false then
	script.Parent.Text = "Auto: OFF"
elseif auto == true then
	script.Parent.Text = "Auto: ON"
end
script.Parent.MouseButton1Click:Connect(function()
	local player = script.Parent.Parent.Parent.Parent.Parent
	if auto == false then
		auto = true
		script.Parent.Text = "Auto: ON"
		while auto do
			wait(0.1)
			player.Clicks.Value += 1 * player.Multi.Value
			player.leaderstats["Total Clicks"].Value += 1 * player.Multi.Value
			local chance = math.random(1,10)
			if chance == 1 then
				player.Gems.Value += math.random(0.25,1)
				C:FireClient(player,"MultiUp2")
			end
		end
	else
		if auto == true then
			auto = false
			script.Parent.Text = "Auto: OFF"
		end
	end
end)

And here’s the code for the remoteevent:

local rs = game:GetService("ReplicatedStorage")
local MU = rs:WaitForChild("Server"):WaitForChild("MultiUp")
MU.OnServerEvent:Connect(function(plr,arg)
	if arg == "automultiup" then
		plr.Multi.Value += string.format('%.1f',math.random(0.1,0.15))
		print("recieved data")
	elseif arg == "multiup" then
		plr.Multi.Value += string.format('%.1f',math.random(0.05,0.1))
		print("recieved data")
	end
end)

For some reason, the output does print received data and all that, but the Multi value never goes above 1 inside of player. There are no errors, but it seems decimals don’t really work? Can someone help please?

math.random truncates the arguments to integers so in your example, your math.random section of the RemoteEvent script truncates the argument to 0.

1 Like

Client-sided changes to leaderstats wont do anything on the server, as it is client-sided.
For example:
If a local script were to change a number value from 0 to 1, the client would display it as 1, because that is what the client sees.
However, the server would be displaying it as 0, because the change was client-sided.
For leaderstat changes, you want to have an event to get fired to change the value through the server, and not the client.

thats literally what im doing bro it runs a remoteevent and the remoteevent doesn’t add the multi value bruh lmao

Ah I see, so how would I go about doing it?

didnt see that, my bad.
However, i did see that in the button GUI you were adding to a value, so thats what i was pointing out.

edit: just noticed that in the button gui YOU ARE USING A SCRIPT. May i ask if the gui is in StarterGui?
If so, try using a LocalScript instead.
Im confused. Ive never seen anyone use a normal script inside of a button GUI, nor have i seen anyone give information directly from the server to the client through a gui.