Hello everyone,
I am currently trying to make a gun system with a reload system.
The client basically sends the current IntValues in the gun (ammo = 0, maxAmmo = 2, reserve = 99) to the server when the gun has 0 ammo left.
A server script in the gun then picks the FireServer of the client up and gets the values. It then compares the ammo and maxAmmo and substracts the needed amount from the reserveAmmo and sends it back to the client, but only the reserveAmmo still stays at 99.
This is the server script:
local function onRl(plr)
local amount = 0
local need = maxAmmo.Value - ammo.Value
if rAmmo.Value > need then
amount = need
else
amount = maxAmmo.Value
end
ammo.Value += amount
rAmmo.Value -= amount
rl:FireClient(plr, ammo.Value, maxAmmo.Value, rAmmo.Value)
end
rl.OnServerEvent:Connect(onRl)
I tried to put the IntValues in a configuration, or to just put them in the Gun Tool, but it did not work. Does someone has a solution to this problem?
Yea that is true, but the server should actualy change the reserve Value, but it does not for whatever reason even though it does change the ammo Value.
Im gonna try to find a article to help, in the meantime try changing the remote events to a remote function. This might not (probably wont) solve the issue but it will help with debugging and script efficiency.
I remember this as well from when I was beginning. Try adding print functions to find where the exact error is.
Sorry , I checked out my local script and tried to set the ammo.Value over the client instead of server…
Thanks for your help, I would never figured this out that the client can’t change IntValues.