I have created a script for my friend's game. The script is supposed to clone particles when a player levels up, the particles are very specific and are within the script. I have tested this in Roblox Studio "Play" mode and in a live server, the Particles don't clone themselves and Sound:Play() only works after removing the coding up to
script.Parent.Parent.Parent.Parent.Character.Torso.ParticleEmitter.Parent = nil.
The script is located in ServerScriptService as a regular script. I've narrowed it down to this snippet of coding, after running print() on each line:
on = false
function onLevelUp(player, XP, level)
if player.Character~=nil then
for i = 1,5 do
script.Parent.Parent.Parent.Parent.Character.Torso.ParticleEmitter.Parent = nil
on = false
local e = script.ParticleEmitter:Clone()
e.Parent = script.Parent.Parent.Parent.Parent.Character.Torso
script.Sound:Play()
wait(3)
on = true
end
end
Thanks for reading/replying.

3 comments
Is filtering disabled?
No filtering is enabled
try running an IF statement to check if a particle emitter already exists at the beginning of your function. It would error if the particle didn't exist yet, unless you already have one there. Nothing in your code shows that one does tho