EJQuik89
(eejay)
#1
I was trying to make a store system in my game, and I get this error that I don’t know how to fix. Here’s the code that’s erroring:
event4.OnServerEvent:Connect(function(player, pet, cost)
print(cost)
print(player.leaderstats.Cash.Value)
if tonumber(player.leaderstats.Cash.Value) >= tonumber(cost.Value) then -- Errors here
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - cost
petGive:Fire(player, pet)
end
end)
Both print statements return what the values are supposed to be, not nil.
xGOA7x
(Cairo)
#2
You should try removing the tonumber()
functions, one of the values may be returning nil
from that.
Edit: remove Value
.
1 Like
So if the value is supposed to be cost
, then what is cost.Value
?
1 Like
EJQuik89
(eejay)
#4
Thank you, I was just working with so many variables so I kinda had a brain fart.
2 Likes
EJQuik89
(eejay)
#5
I ran the code again, and I’m kind of confused. The server code is mixing up the pet and cost variables while on the client everything’s fine
You’re not including player
in FireServer(pet, cost)
by accident, are you?
1 Like
EJQuik89
(eejay)
#7
Thank you! It works as intended now!
1 Like