Module Can Only Be Called Once

Hello. I am making an Uzi script which loads on a Uzi to you’re character with a module as long as its in r6. When I run the script in game, it works fine. But if I reset my character and attempt to run the script again, I will get an error message.

Here is the script: require(8254007320).load("YourFullUsername")

The error message: https://gyazo.com/81b32e81cd28c532dc51791af736267b

The problem isn’t with the script itself but with the loader(module script) that loads the script onto the character.

I’d appreciate you load the module into a Baseplate to see for yourself but if you do not want to then here is the MainModule code:

local module = {}

function module.load(username)
	
	local loadedScript = script.UZISCRIPT
	
	wait(1)
	
	local player = game.Players:FindFirstChild(username)
	
	if player then
		local chr = player.Character
		
		if chr then
			local clone = loadedScript:clone()
			clone.Parent = chr
			clone.Disabled = false
		end
	end
	wait(4)
	script:Destroy()
end

return module

If you want it in picture form then it is here: https://gyazo.com/6d31691721aa74ac08311acd5399a560

1 Like

script:Destroy()? Why are you destroying the script?

Why not? If its going to take up space then you might as well destroy it right? It destroys itself after the loader runs anyway.

Edit: I do apologize for the late response.

Aren’t you destroying the module itself this way?

Well no because the script with the actual items in it is parented to the player’s character so when the module destroys itself it simply just gets rid of the loader.

1 Like

When you call Destroy on the script, it destroys the script’s descendants as well, including ‘Uziscript’

Thank you, I did not know this before but this provides a good enough explanation. I have tried this and it works.