I was watching a tutorial on how to make a Pet Hatching System and my script didn’t work when I have the amount of cost. When I changed the operator, >= to <=, it worked but only when I have less than the cost. When I do >= it doesn’t work at all
local cost = 500
local petModule = require(game.ServerScriptService.ModuleScripts:WaitForChild("PetModule"))
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player.leaderstats.Diamonds.Value >= cost then
player.leaderstats.Diamonds.Value = player.leaderstats.Diamonds.Value - cost
local pet = petModule.chooseRandomPet()
print(pet.Name.." selected")
end
end)
script.Parent.ClickDetector.MouseClick:Connect(function(player)
print(player.leaderstats.Diamonds.Value)
if player.leaderstats.Diamonds.Value >= cost then
player.leaderstats.Diamonds.Value = player.leaderstats.Diamonds.Value - cost
local pet = petModule.chooseRandomPet()
print(pet.Name.." selected")
end
end)
Try adding a print statement. After setting the value, what does the print say?
That found the problem out, thanks for the debugging but I still don’t know how to fix it.
The problem is, it keeps the same value (0) and when I change it to 500, it still prints the same value I had before I changed it, which is my starting value
The thing you are missing out on is there are two console’s in the studio, one a client-side and the other one serverside. When you use the console right after starting the game, it will use the client-side console. If you want to change the value serverside you should press the button below