So I made this stat handler for the client but its not working idk why it works for every other thing, know I dint name anything wrong I prnted it it should all be right als in the players stats all the names are right. Here’s the part of my script:
statsEvent.OnServerEvent:Connect(function(player, amount, symbol, stat)
print(amount, symbol, stat)
if symbol == "+" then
player.Values[stat].Value += amount
elseif symbol == "-" then
player.Values[stat].Value -= amount
elseif symbol == "*" then
player.Values[stat].Value *= amount
elseif symbol == "/" then
player.Values[stat].Value /= amount
elseif symbol == "=" then
player.Values[stat].Value = amount --- this line is error
end
end)
I get this error on the line I marked: invalid argument #2 (string expected, got Instance)
statsEvent.OnServerEvent:Connect(function(player, amount, symbol, stat)
if typeof(amount) == 'Instance' then
warn('You sent an Instance as the argument for amount')
if pcall(function() return amount.Value end) then
amount = amount.Value
else
warn('Cannot Fix this, please put in a valid value')
return
end
end
if symbol == "+" then
player.Values[stat].Value += amount
elseif symbol == "-" then
player.Values[stat].Value -= amount
elseif symbol == "*" then
player.Values[stat].Value *= amount
elseif symbol == "/" then
player.Values[stat].Value /= amount
elseif symbol == "=" then
player.Values[stat].Value = amount
end
end)
But also, realistically I wouldn’t have an event like this, because a hacker can have complete control over their stats with something like this.