I was testing my game today with another tester and I ran into a problem which occurred when 2 users fired a remote event to a server script, with that server script using a module script to use its code. Instead of both players getting a Particle Emitter like it was intended to do, it only effected 1 player?
Is this a Roblox issue or a issue with my use of module scripts?
Are the missing quotation marks from the client script a typo? If they are not, they’re probably not complete strings causing an error. Otherwise, everything seems fine
First of all, the quotation marks, second of all, I wouldn’t recommend requiring the module right then and there last minute, and third of all, you’re saying “Module:Test(p)”, however, that isn’t the correct syntax for it. When declaring functions in a module, you access them like this:
examplemodule.Function(plr, args...)
I’m pretty sure what you’re saying is impossible, remoteevents don’t get mixed up. One player is one player and another player is another player, unless p in your script has been interfered with and has been improbably set to another player.
I think the p being sent to the module script is being set to another player when 2 players use it at the same time, like you said. How would I go about solving that problem?
script.Parent.OnServerEvent:Connect(function(p, Value)
if debounce == false then
debounce = true
if Value == "Hola" then
Module = require(game.ServerScriptService.Hola)
Module:Test(p)
end
end
end)
Module:
local Aura = {}
function Aura:Test(p)
c = p.Character
for u, v in pairs(c.LowerTorso:GetDescendants()) do
if v:IsA("ParticleEmitter") and v.Name == "Aura" then
v:Destroy()
end
if v:IsA("Sound") and v.Name == "Burst" then
v:Destroy()
end
end
local New_Aura = game.ReplicatedStorage.Test:Clone()
New_Aura.Name = "Aura"
New_Aura.Parent = c
end
return Aura
Shouldn’t you be cloning it into the LowerTorso instead of the character model?
This is incorrect. You can require a library any number of times, modules just have caching behaviour, their contents are only run once on the first require, and then any subsequent require calls will return the same item that is returned from the initial call.
Maybe here’s the problem? If the debounce is placed on the server, then when two players fire the same function at the same time obiously only 1 player will get the particles. Just removing that debounce on the server should fix the problem