Hello! Basically, I created a module that works fine, but what is wrong with the server side?
Module:
local module = {
addApple = function(appleAmount, appleValue)
if appleAmount ~= nil and appleValue ~= nil then
local remainingApple = appleValue.Value + appleValue
if remainingApple > 0 then
applesCollected(appleValue, remainingApple)
else
appleValue.Value = remainingApple
end
end
end
}
return module
Server:
rEvents.addApple.OnServerEvent:connect(function(plr)
local appleAmount = 15
local appleValue = plr.Apples
plr.Apples.Value += module.addApple(appleAmount, appleValue)
end)
The thing is about server script, if I use plr.Apples.Value = module.addApple it’s works without any problem but it won’t then add the value that I needs, same with - or *
appleAmount = ‘15’ on the server side, appleValue = plr.Apples, but in the end on module ‘.Value’ makes it: plr.Apples.Value so mainly appleValue.Value = plr.Apples.Value
Ok, look I’m not going to sit here for an hour just fighting about this. appleValue is an INSTANCE. you are try to add ITS VALUE to THE INSTANCE ITSELF.
Okay, I’m done, read what I quoted and figure it out yourself. Also, ask anyone, if they know how to script and read it, they will point out the exact same thing I did.
As I said before the module script works FINE, the only problem is server side one, since if I put plr.Apples.Value = module.addApple(appleAmount, appleValue) it works fine without any errors, but if I’m trying add the value for example: plr.Apples.Value += module.addApple(appleAmount, appleValue) it won’t work well. I just don’t understand how to add values from modules, it’s the thing.