Ok so there is a lot of confusion here on my end and on your end so im gonna visualize it using studio. Your setup doesn’t have to be the same this is just how i did it.
First off this is what im talking about ^^^.
I’m gonna start off with the module script
local module = {}
module.Effects = function(Effect, Origin, Range)
for i,Player in pairs(game.Players:GetPlayers()) do
if (Origin.Position - Player.Character.HumanoidRootPart.Position).Magnitude <= Range then
game.ReplicatedStorage.RemoteEvent:FireClient(Player,Effect)
end
end
end
module.Moves = function(Move, Origin, Range)
if Move == "Punch2" then Range = 0 end -- If the move is punch2 then the effect will not be rendered.
module.Effects(Move, Origin, Range) -- Feed the move info given into the effect function
print("THIS IS WHERE THE LOGIC FOR HITBOXES AND DAMAGE GOES!!!")
end
return module
I don’t have two seperate modules but instead one in this example. One that will handle rendering effects and one that will handle the logic for everything else.
In the function “Effects” I make it so only people within a specified range will be able to see the effect through the RemoteEvent in ReplicatedStorage.
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(Var1,Var2)
if Var1 == "Punch" then
local Part = Instance.new("Part", workspace)
Part.CFrame = Var2.CFrame
print("CLIENT VFX")
end
end)
This is the client script. It’s simple and doesn’t need much explaining needed. If the client recieves any argument like “Punch” then it will spawn a part on the Origin position also being the players humanoidrootpart who fired the module.
local MoveModule = require(game.ServerStorage.ModuleScript)
script.Parent.Activated:Connect(function()
local Character = script.Parent.Parent
print("I FIRED FROM A TOOL!")
MoveModule.Moves("Punch",Character.HumanoidRootPart, 100)
end)
And this is the tool used to fired the module itself.
Together you should have something like this.
A part infront of the player who used the tool.
And on the server it should have nothing like this:
Hopefully this should clear up any confusion.