What do you want to achieve?
I have been writing a gun mechanics system, and I was making a reload script so that when the user runs out of ammunition, a boolean value will return as true, and they cannot shoot unless the button ‘R’ is pressed which will trigger the boolean to return as false.
What is the issue?
In my firing script it returns “out of ammo” but in my reload script it doesn’t run any of the script according to my output, except for variables and the first two events of course. It doesn’t fire the remote event nor does the remote event connect back.
What solutions have you tried so far?
I have tried adding debounces such as having checks to see if the user has the tool equipped in order to reload, but it didn’t even get as far to check if the boolean is true.
I have also tried using hidden developers to ask for what I did wrong, no response from up to 5 times.
local c = script.Parent.Parent:WaitForChild('Configuration') local rs = game:GetService('ReplicatedStorage') local uis = game:GetService('UserInputService') local t = script.Parent.Parent local equipped = false t.Equipped:Connect(function() equipped = true end) t.Unequipped:Connect(function() equipped = false end) uis.InputBegan:Connect(function(key) if (equipped == true) then if (key == Enum.KeyCode.R) then if (c.out.Value == true) then local cache = rs:WaitForChild('CacheReload') cache:FireServer(c.out.Value,c.use.Value,c.left.Value) print('server fired') end end end end)
local rs = game:GetService('ReplicatedStorage') rs:WaitForChild('CacheReload').OnServerEvent:Connect(function(bool,use,left) if (bool == true) then print('out of ammo, server says') use.Value = use.Value + 4 left.Value = left.Value - 4 bool.Value = false print('ammo replenished') end end)
If you can solve my mystery, and understand what I did wrong, please tell me the name of the line and what I did wrong, there are no errors in my output.