Module damages but when i use something else player goes back to full hp

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    Hello i want to make module damage for server

  2. What is the issue?
    if i damage with module and after hit with sword players heal goes back to 100 which means module never done damage and sometimes it shows like player dead but its not prob bcs of the same thing

  3. What solutions have you tried so far?
    I tried to make it fired from a script not a local script but when i tried this it was giving errors about the module
    tried to make another module for the damage but still the same
    damage script i use in the module

local SquareHitBox = Instance.new("Part")
	SquareHitBox.Size = Vector3.new(DamageRange.X, DamageRange.Y, DamageRange.Z)
	SquareHitBox.Transparency = 1
	SquareHitBox.CanCollide = false
	SquareHitBox.Anchored = true
	SquareHitBox.Name = "Hitbox"
	SquareHitBox.Massless = true
	SquareHitBox.Position = Mouse.p
	game.Debris:AddItem(SquareHitBox,6)	
	SquareHitBox.Parent = game.Workspace.Effects 

	delay(4,function()
		local alr_hit = {}

		local function detect()
			local ovParams = OverlapParams.new()
			ovParams.CollisionGroup = "Default"
			ovParams.FilterType = Enum.RaycastFilterType.Blacklist
			ovParams.MaxParts = false
			local parts = workspace:GetPartsInPart(SquareHitBox, ovParams)

			for i,p in pairs(parts) do
				local hit = p.Parent
				local hum = hit:FindFirstChild("Humanoid")
				if hum and not table.find(alr_hit, hum) and not (hum == Character.Humanoid) and hum:GetState() ~= Enum.HumanoidStateType.Dead then
					for i,p in pairs(parts) do
						local hit = p.Parent
						local hum = hit:FindFirstChild("Humanoid")
						table.insert(alr_hit, hum)
						hit.Humanoid:TakeDamage(15)
					end
				end
			end
			end
		coroutine.wrap(function()
			while SquareHitBox.Parent == game.Workspace.Effects do
				detect()
				task.wait()
			end
		end)()
	end)

the local script which im getting the module from

-- Player Variables --
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local char = plr.Character
local Tool = script.Parent

-- Game Service --
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
-- Folders--
local SkillsFolder = ReplicatedStorage:WaitForChild("Skills")
local BackEndFolder = SkillsFolder:WaitForChild("BackEnd")
local SkillDataFolder = BackEndFolder:WaitForChild("SkillData")
local AbilitiesFolder = BackEndFolder:WaitForChild("Abilities")
-- Bool Values--
local ToolEquip = false
-- Key Bind Table -- 
KeyBinds = { -- Add Whatever Key you'd prefer
	Z = nil,
	X = nil,
	C = nil,
	V = nil,
	B= nil
}
-- Ability Info --
local Ability = "String" -- Change to Whatever ability your trying to use
local SkillData = require(SkillDataFolder[Ability])
local AbilityModule = require(AbilitiesFolder[Ability])

for i, Info  in pairs(SkillData) do  -- This basically just sets different ability moves to each KeyBind again you can change it to your own keys
	if Info.Key == "Z" then
		KeyBinds.Z = Info.Name
	elseif Info.Key == "X" then
		KeyBinds.X = Info.Name
	elseif Info.Key == "C" then
		KeyBinds.C = Info.Name
	elseif Info.Key == "V" then
		KeyBinds.V = Info.Name
	elseif Info.Key == "B" then
		KeyBinds.B = Info.Name
	end
end


 -- User Input Service --
UserInputService.InputBegan:Connect(function(input, isGui)
	if isGui then return end
	if input.KeyCode == Enum.KeyCode.Z and KeyBinds.Z ~= nil and char.Humanoid:GetState() ~= Enum.HumanoidStateType.Jumping and  char.Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall and char.Humanoid:GetState() ~= Enum.HumanoidStateType.FallingDown and char.Humanoid:GetState() ~= Enum.HumanoidStateType.Dead and char.CanDoAnything.Value == true then
		print(KeyBinds.Z)
		AbilityModule[KeyBinds.Z](plr)
	elseif input.KeyCode == Enum.KeyCode.X and KeyBinds.X ~= nil and char.Humanoid:GetState() ~= Enum.HumanoidStateType.Jumping and  char.Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall and char.Humanoid:GetState() ~= Enum.HumanoidStateType.FallingDown and char.Humanoid:GetState() ~= Enum.HumanoidStateType.Dead and char.CanDoAnything.Value == true then
		print(KeyBinds.X)
		AbilityModule[KeyBinds.X](plr)
	elseif input.KeyCode == Enum.KeyCode.C and KeyBinds.C ~= nil and char.Humanoid:GetState() ~= Enum.HumanoidStateType.Dead and char.CanDoAnything.Value == true then
			print(KeyBinds.C)
			AbilityModule[KeyBinds.C](plr)
	elseif input.KeyCode == Enum.KeyCode.V and KeyBinds.V ~= nil and char.Humanoid:GetState() ~= Enum.HumanoidStateType.Jumping and  char.Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall and char.Humanoid:GetState() ~= Enum.HumanoidStateType.FallingDown and char.Humanoid:GetState() ~= Enum.HumanoidStateType.Dead and char.CanDoAnything.Value == true then
			print(KeyBinds.V)

			AbilityModule[KeyBinds.V](plr)
		elseif input.KeyCode == Enum.KeyCode.B and KeyBinds.B ~= nil then
			print(KeyBinds.B)

			AbilityModule[KeyBinds.B](plr)
		end
end)


I guess that’s because you damage player by local script and it damages only for yourself and when someone damage your humanoid or update it you see your hp is full again. Use remotes.

i was using modules cause someone told me they are better cant i transform it to a normal script ?

When you require module script by local script you run it on local script.

i tried to transfer it to a normal script but it was giving requested module error

If you want create hit box you can use server script

game.Players.PlayerAdded:Connect(function(Player)



	Player.CharacterAppearanceLoaded:Connect(function(Char)
        local hitbox = Instance.new("Part")
        hitbox.Parent = Char
        hitbox.Name = "hitbox"
        hitbox.Massless = true
        hitbox.Transparency = 1
		hitbox.CanCollide = false
		hitbox.Size = Vector3.new(4.15, 5, 2.6)
    end)
end)

Also you can create remote and make on server event script

local remote = game:GetService("ReplicatedStorage").YourRemote

remote.OnServerEvent:Connect(function(plr)
    -- to find your character you can use this loop
    for i,v in ipairs(workspace:GetChildren()) do
	    local human = v:FindFirstChild("Humanoid")
		local torso = v:FindFirstChild("Torso") or v:FindFirstChild("HumanoidRootPart")
		if human and torso and v.Name == plr.Name  then
              -- do something with your character
        end
end)

oh okay thanks lemme try it real quick

To fire server you need to do remote:FireServer() from your local script
and you don’t need to insert your player when you fire server from local script like this remote:FireServer(plr) it doing it automatically.
Just point it when you make your remote.OnServerEvent:Connect(function(plr)
end) in server script.
Read a bit this Remote Functions and Events.

I want to give you an advice use server scripts because hackers can use local script) also if you change something with use local script it won’t show up for server.

That’s why you should make defense and some checks in server script for remote events.

oh so i have to make it from local script

i cant fire it from modules ig

Say if you got some problems with scripts I will try to help you.

im trying to make everything fit now it seems like it working well since module sending parts from client i cant detect the parts and make them hitboxes thats the only problem but not a big deal ig im trying to make it perfect rn

i was always using normal scripts but peoples said modules are much better thats the reason i started using modules but i see actually i was doing the right thing

using only a localscript remote event and a script is much better way than modules ?

A ModuleScript is a type of Lua source container that runs once and must return exactly one value. It can’t replace remote events (they are different) that’s why i can’t say is it better or worser.
I am about if you require module by local script it will run module script’s lua like if you use that lua in your script but it can’t run it from server script when you require module from local script.

If you require it from server script then it will run module script’s lua like if you use that lua in your script at the beggining.

Remotes is something like connection between server scripts and local scripts.

but theres no difference right ?