How can I require a Module Script within a tool? Health + Ammo Drop

Currently, I’m trying to code a player drop system for health and ammo. The ammo is located inside of a table in a module script (The module script is inside of the tool). But, I can’t figure out how to require the Module Script in the tool from the server.

The “GunStatistics” script is undefined. I don’t know how to require it (or if I can). Anything help!

Here is my script:

local healthDropModel = script:WaitForChild("HealthAmmo")

local healthGain = 60
local ammoGain = 30
game.Players.PlayerAdded:Connect(function(plr)
print(1)
	plr.CharacterAdded:Connect(function(char)
		print(2)

		local humanoid = char:WaitForChild("Humanoid")

		humanoid.Died:Connect(function()
			print(3)

			local deathPos = char.HumanoidRootPart.Position

			wait(1)

			local newHealthModel = healthDropModel:Clone()
			newHealthModel.Position = deathPos
			newHealthModel.CanCollide = false
			newHealthModel.Anchored = true
			newHealthModel.Parent = workspace
			print(4)
			newHealthModel.Touched:Connect(function(hit)
			print(5)
				local humanoid = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")

				if humanoid then
					newHealthModel:Destroy()

					humanoid.Health += healthGain
					
					GunStatistics.EquipedTool.Module.Bullet.TotalAmmo += ammoGain
				end
			end)
		end)
	end)
end)


Bullet Statistics:

GunStatistics.Bullet = {
	TotalAmmo = 120,
	Capacity = 30,
}

All the stuff I tried was not helpful to bring to this conversation.

Let me know how I should go about this.

What are you trying to do here? Please elaborate. Are you trying to require the module for every player from the server?

All I’m trying to do is access a table from a module script within the equipped tool. Whenever you die it spawns a part at the dead mans position. Then, anyone would be able to walk up to the part and touch it to add health and ammo. The ammo is inside of a table in the tool and I need to add to it from another script from the server.

Well, what were they? At least comment it out so we can take a look. Maybe you missed something, I don’t know.

Okay, I just got somewhere but the bullets are removed on the client and not on the server. When I add them from the server they aren’t actually adding to the clip. I’ll provide the new script along with my reload function that removes the ammo.

New Script:

local healthDropModel = script:WaitForChild("HealthAmmo")

local healthGain = 60
local ammoGain = 30
game.Players.PlayerAdded:Connect(function(plr)
print(1)
	plr.CharacterAdded:Connect(function(char)
		print(2)

		local humanoid = char:WaitForChild("Humanoid")

		humanoid.Died:Connect(function()
			print(3)

			local deathPos = char.HumanoidRootPart.Position

			wait(1)

			local newHealthModel = healthDropModel:Clone()
			newHealthModel.Position = deathPos
			newHealthModel.CanCollide = false
			newHealthModel.Anchored = true
			newHealthModel.Parent = workspace
			print(4)
			newHealthModel.Touched:Connect(function(hit)
			print(5)
				local humanoid = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")

				if humanoid then
					newHealthModel:Destroy()

					humanoid.Health += healthGain
					
					for _, descendant in ipairs(humanoid.Parent:GetDescendants()) do
						if descendant:IsA("Tool") then
							local GunStatistics = require(descendant:FindFirstChild("GunStatistics"))
							GunStatistics.Bullet.TotalAmmo += ammoGain
							print(GunStatistics.Bullet.TotalAmmo)
						end
					end
					--humanoid.Parent.EquipedTool.Module.Bullet.TotalAmmo += ammoGain
				end
			end)
		end)
	end)
end)


Reload:

function GunHandler.Reload()
	EquipedTool.Firing,EquipedTool.CanFire,EquipedTool.Reloading = false,false,true
	if script:GetAttribute("Aiming") then
		GunHandler.Aim(false)
	end
	print(EquipedTool,EquipedTool.Model,EquipedTool.Module.Bullet.TotalAmmo,EquipedTool.Model:GetAttribute("AmmoInMag"))
	local ReloadAnimation = nil
	if EquipedTool.Model:GetAttribute("AmmoInMag") == 0 then
		ReloadAnimation = "HotReloadAnimation"
	else
		ReloadAnimation = "TacticalReloadAnimation"
	end
	
	if EquipedTool.Module.Bullet.TotalAmmo >= 1 then
		AnimationHandler:Play(EquipedTool.Animations, ReloadAnimation,0.100000001,2,2.5)
	end
	

	local Function = nil
	Function = EquipedTool.Animations[ReloadAnimation].Stopped:Connect(function()
		Function:Disconnect()
		if Character.Rig and Character.Rig:FindFirstChildOfClass("Tool") then
			local ammoInMag = EquipedTool.Model:GetAttribute("AmmoInMag")
			local totalAmmo = EquipedTool.Module.Bullet.TotalAmmo
			local capacity = EquipedTool.Module.Bullet.Capacity
			if totalAmmo > 0 then
				local ammoNeeded = capacity - ammoInMag
				if totalAmmo >= ammoNeeded then
					EquipedTool.Model:SetAttribute("AmmoInMag", capacity)
					EquipedTool.Module.Bullet.TotalAmmo = totalAmmo - ammoNeeded
				else
					EquipedTool.Model:SetAttribute("AmmoInMag", ammoInMag + totalAmmo)
					EquipedTool.Module.Bullet.TotalAmmo = 0
				end
			else
				EquipedTool.Model:SetAttribute("AmmoInMag", ammoInMag)
			end
			EquipedTool.CanFire,EquipedTool.Reloading = true,false
			if Services.UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton2) and Character.Humanoid and Character.Humanoid.Health ~= 0 then
				GunHandler.Aim(true)
			else
				AnimationHandler:Play(EquipedTool.Animations, "IdleAnimation",1)
			end
		else
			EquipedTool.CanFire,EquipedTool.Reloading = true,false
		end
	end)
end

The print outputs are as follows:
150 - Server - HealthAmmo:38 (This is when you touch the cloned part)
AK-101 109 25 - Client - GunHandler (This is when you reload) (The 109 shows TotalAmmo, while 25 shows “AmmoInClip”

The reload function is inside of a ModuleScript which is on the client in StarterPlayerScripts.

Any ideas as to why it’s able to add to TotalAmmo but doesn’t actually affect the amount of ammo left over? I tried to do it on both the client and the server when adding the ammo. But, it still says it’s adding to it but it never actually does. Please help I’m so stumped.