I got a tool with 3 IntValues: Mag, MagSize, and Reservoir. When the player presses R, it's supposed to reload their gun, but as I stated in the title, the reload event fires but the values do not update. I should mention both script snippets are inside the tool so I don't know if that's affecting it. Also I'm not completely get what you're supposed to put in the parentheses after the functions so that might be affecting it as well.
Local Script:
CanReload = false
function OnEquipped(playerMouse)
CanReload = true
local clone = GUI:Clone()
local TextLabel = clone:WaitForChild("TextLabel")
TextLabel.Text = Mag.Value.."/"..Reservoir.Value
clone.Parent = Player.PlayerGui
Mouse = playerMouse
ExpectingInput = true
UpdateMouseIcon()
end
function OnUnequipped()
CanReload = false
if Player.PlayerGui:FindFirstChild("Magazine") then
Player.PlayerGui.Magazine:Destroy()
end
ExpectingInput = false
UpdateMouseIcon()
end
Tool.Equipped:Connect(OnEquipped)
Tool.Unequipped:Connect(OnUnequipped)
UIS.InputBegan:Connect(function(Input)
local reloaddebounce = false
if Input.KeyCode == Enum.KeyCode.R then
if CanReload then
reloaddebounce = true
Reload:FireServer(Tool)
wait(1)
reloaddebounce = false
end
end
end)
UserInputService.InputBegan:Connect(function (input, gameHandledEvent)
if gameHandledEvent or not ExpectingInput then
return
end
Mag.Changed:Connect(function(Tool)
if Player.PlayerGui:FindFirstChild("Magazine") and Player.PlayerGui:FindFirstChild("Magazine"):FindFirstChild("TextLabel") then
Player.PlayerGui.Magazine.TextLabel.Text = Mag.Value.."/"..Reservoir.Value
end
end)
Reservoir.Changed:Connect(function(Tool)
if Player.PlayerGui:FindFirstChild("Magazine") and Player.PlayerGui:FindFirstChild("Magazine"):FindFirstChild("TextLabel") then
Player.PlayerGui.Magazine.TextLabel.Text = Mag.Value.."/"..Reservoir.Value
end
end)
Script:
ReloadEvent.OnServerEvent:Connect(function(clientThatFired, Tool)
local needed = MagSize.Value - Mag.Value
if Reservoir.Value < needed then
Mag.Value = Mag.Value + Reservoir.Value
Reservoir.Value = 0
else
Mag.Value = Mag.Value + needed
Reservoir.Value = Reservoir.Value - needed
end
end)
Sorry for bad script layout, I'm big nob.

1 comment
That's weird, I'm not getting any errors.