I am trying to make a script so that when you click on the button, you can pay with materials to build the house.
game.Players.PlayerAdded:Connect(function(player)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remotes = ReplicatedStorage:WaitForChild("Remotes")
local leaderstats = player:WaitForChild("leaderstats")
local Inventory = player:WaitForChild("Inventory")
game.ReplicatedStorage.Remotes.BuyHouse.OnServerEvent:Connect(function()
if leaderstats.Wood.Value >= 50 then
leaderstats.Wood.Value = player.leaderstats.Wood.Value - 50
Inventory.BoughtHouse.Value = true
ReplicatedStorage.Text.Value = "-50 Wood"
print("Enough coins")
elseif leaderstats.Wood.Value <= 50 then
ReplicatedStorage.Text.Value = "Not Enough Materials!"
wait(2)
print("Not enough coins!")
ReplicatedStorage.Text.Value = "Press E to open the house upgrade menu!"
end
end)
end)
For some reason, no matter how much wood I have, it always says "Not Enough Materials".
Any help would be appreciated!

2 comments
Try to print leaderstats.Wood.Value and see what it gives.
Yeah there is nothing wrong with the statement, make sure you are setting Wood.Value on the server as setting it on the client won't replicate it.