Module doesnt run even without errors

So I made this module where it makes a part on the position That I put. But it doesn’t make the part. This is the module:

local ShockWave = {}

function ShockWave.MakePart(position)
   local Sphere = Instance.new('Part')
   Sphere.Name = "ShockWave"
   Sphere.Shape = Enum.PartType.Ball
   Sphere.Parent = workspace
   Sphere.Position = position
end


return ShockWave

this is the script that runs the module:

ShockWave.MakePart(humanoid.Parent.HumanoidRootPart.Position)

2 Likes

What is the module parented to? Did you ever call it?

Yeah I required it:

local ShockWave = require(game.ServerScriptService.Modules.Visualiser.Modules.ShockWave)

Because no one responded in 5 hours

Could you put the full code of where the

ShockWave.MakePart(humanoid.Parent.HumanoidRootPart.Position)

is located?

wait(0.1)

local Players = game:GetService("Players")

local plr = script.Parent.Parent.Parent

local char = plr.Character

local Idle = char.Humanoid:LoadAnimation(script.Animations.Idle)

local Equip = char.Humanoid:LoadAnimation(script.Animations.Equip)

local equipped = false

local attacking = false

local RaycastHitbox = require(game.ReplicatedStorage.Remotes.Modules.RaycastHitbox)

local ShockWave = require(game.ServerScriptService.Modules.Visualiser.Modules.ShockWave)

local Hitbox = RaycastHitbox:Initialize(script.Parent.Weapon)

durability = 6

local attack = char.Humanoid:LoadAnimation(script.Animations.Attack)

local broken = false

Hitbox.OnHit:Connect(function(hit, humanoid)

if humanoid.Parent ~= char then

script.Parent.Weapon.Hit:Play()

local damage = math.random(20,30)

local Speed = 20

local Force = 30000

local TotalForce = Force

local KnockBack = Instance.new("BodyVelocity",hit.Parent:FindFirstChild("Torso"))

KnockBack.MaxForce = Vector3.new(TotalForce,TotalForce,TotalForce)

KnockBack.Velocity = plr.Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * Speed

game.Debris:AddItem(KnockBack,0.1)

ShockWave.MakePart(humanoid.Parent.HumanoidRootPart.Position)

humanoid:TakeDamage(damage)

spawn(function()

humanoid.Parent.Ragdoll.Ragdolled.Value = true

wait(1)

humanoid.Parent.Ragdoll.Ragdolled.Value = false

end)

if durability == 0 then

Hitbox:HitStop()

script.Parent.Weapon.Transparency = 1

script.Parent.Weapon.B:Play()

script.Parent.Weapon.ParticleEmitter:Emit(50)

local Player = Players:GetPlayerFromCharacter(script.Parent.Parent)

game.ReplicatedStorage.Remotes.Message.MessageEdit:FireClient(Player,"text","Your bat shatters into multiple pieces",Color3.new(1, 0.298039, 0.298039))

broken = true

Equip:Stop()

Idle:Stop()

attack:Stop()

wait(2)

script.Parent:Destroy()

end

durability = durability - 1

end

end)

script.Parent.Equipped:Connect(function()

if not broken then

Equip:Play()

Equip.Stopped:Wait()

Idle:Play()

equipped = true

else

plr.Character.Humanoid:UnequipTools()

end

end)

script.Parent.Unequipped:Connect(function()

equipped = false

end)

script.Parent.Activated:Connect(function()

if not attacking and equipped and durability >= 0 then

attack:Play()

attacking = true

script.Parent.Weapon.Prepare:Play()

wait(0.35)

Hitbox:HitStart()

script.Parent.Weapon.Swing:Play()

wait(0.4)

Hitbox:HitStop()

wait(2)

attacking = false

wait(0.4)

end

end)
1 Like

Is this all in a Script or a LocalScript?

Its in a script. Not a local script

Set the position before setting the parent. See this for more information.

2 Likes

This code won’t work at all in a Server Script. You can’t get the character from a ServerScript because you first have to get the LocalPlayer, which is impossible to do on the SERVER.

I’m not using a Local Player. I’m using hitbox module which can detect which part it hits. And humanoid is the humanoid of the object that got hit. also known as the other player

you can literally get the player from PlayerAdded, also server scripts can run in StarterGui which means they can use :FFAOC() to get the player
you can also get the player from a touched event

yea I can keep going

What debugging methods have you attempted? Does MakePart run at all? Does the OnHit function run? You haven’t provided any of this information. Don’t expect people to help you if you haven’t tried to fix it yourself.

1 Like

Ifigured the problem out. I was spawning the part on the HumanoidRootPart Position. And I tested the tool on a custom dummy without a humanoid root part. so it wouldnt run. So I tested with another player.

I think you are making the part but no where it is anchored or welded, so it is quite literally just falling into the void maybe. You could try Sphere.Anchored = true and just see if that works as that may be your issue

2 Likes

that was also part of the issue its just that the script detects a HumanoidRootPart position but the dummy I was testing on didn’t have one

1 Like

So, is this topic solved? If so, mark your reply as the solution.