Greater than equation not working?

So the script detectes if the cash is greater then or equal too the rebirth cost so it works when you press the button once but when you go for a second time it does not work??

local rp = game:GetService("ReplicatedStorage")
local event = rp.Rebirth
local plr = game:GetService("Players").PlayerAdded:Wait()


event.OnServerEvent:Connect(function()
	local othersutff = plr.OtherStuff
	local rebirth = othersutff.rebirths
	local rebirthcost = plr.OtherStuff.rebirthcost
	local cash = plr.leaderstats.Cash
	local wood = plr.leaderstats.Wood
	if cash.Value >= rebirthcost.Value then   
		rebirthcost.Value *= 3.75
		rebirth.Value = rebirth.Value + 0.1
		math.ceil(rebirth.Value)
		math.ceil(rebirthcost.Value)
		cash.Value = 0
		wood.Value = 0
		print(rebirth.Value)
	else
		print("not enough money")
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

can we get more detail on what is happening, like maybe print the cash value and the rebirthcost value before the if statement. Are you sure it’s not because you increase the rebirth cost by 3.75x every time your rebirth?

K, i found the issue but I still dont know what is going on, so when i print i says the cash value is zero but when I go to the folder that it is it says my value is above it.

do you mind making a video or something so I can see what you’re talking about?

the issue might be when converting wood to cash you are doing it locally instead on the server

how would i do it on the server

so the values are to be increased on the server because local scripts can’t change stuff on the server

no like with code im still trying to learn how to do it

So basically you change the value of cash and wood using “Script” scripts instead of “local script” ones

Ut us satubg attenot ti ubdex buk wutg leaderstats, and what is the point of accualy using a localscript instead of a normal script? here is my convert script btw,

local Players = game:GetService("Players")
local leaderstats = Players.LocalPlayer.leaderstats
local wood = leaderstats.Wood
local cash = leaderstats.Cash
local multiplier  = Players.LocalPlayer.OtherStuff.rebirths.Value


script.Parent.MouseButton1Click:Connect(function()
	print(cash.Value)
	cash.Value += wood.Value * multiplier
	wood.Value = 0
end)

could you print multiplier rq? also that script sets wood to 0

I want the wood amount to be set to 0 it is the cash that is not working

do note, 0 * amount will always be 0 so print wood and multiplier

yeah the mutlipier is set to 1 so idk, and it is saying attempt to index nil with ‘leaderstats’

that’s the reason then, leaderstats can’t be found

is it becasue im finding local player in a script?

yes and you seem to be setting it in a local script as well, I just noticed so yeah, that script should be on the server

It comes up with my name in the error were the local player is so do i have to change it if it is a normal script, and i changed it to waitforchild leaderstats to see if that was the issue and now it is saying inex nil with waitforchild

so when the mouse button is clicked, you could fire an event to the server as the event’s first variable thingy will always be the player who the event is coming from

I.E. On(type)Event:Connect(function(PlayerVariable)