My goal is to have a script that perpetually goes through a table (keys being players and values being the values of interest) and halves any entries that are above 0.1, setting all else to 0 (this is a mechanism to reduce the recoil inaccuracy of guns after they fire).
Currently my server script looks like this:
game["Run Service"].Heartbeat:Connect(function()
for k,v in pairs(shared.RecoilTable) do
if v > 0.1 then
v *= 0.5
print("The recoil SHOULD be halved")
else
v=0
print("The recoil SHOULD be set to 0")
end
end
end)
The prints do fire at the correct times whenever I manually increase or decrease the recoil for each player, but for some reason it simply refuses to edit v, weather that be to multiply it by 0.5 or set it to 0, V keeps staying unchanged.
Does anyone know why the script seems to just not be listening to me.
You shouldn’t be using v *= 0.5, I believe the correct usage is v = v * 0.5. And the problem also could be that you should be doing shared.RecoilTable[k] = shared.RecoilTable[k] * 0.5 either of those.