I want to create a ModuleScript that inserts a localscript into everybody's PlayerGui when ran. I have a script that seems to be fine, but everytime I run it, I get no result or "Requested module experienced an error while loading" My scripting ability is shoddy to say the absolute least, so here's the script I tried to make: I'm simply using the command require(game.Workspace.ModuleScript) to test it. What am I doing wrong?

local module = {}
local mightwork = script.LocalScript
function awawa()
for _, player in pairs(game.Players:GetPlayers()) do
	local playerGui = player.PlayerGui
	if playerGui and playerGui:FindFirstChild('mightwork') == nil then
		local mightClone = mightwork:Clone()
		mightClone.Parent = playerGui
		end
	end
end

return module

1 comment

0

You need to prefix module functions with the module table, like so: "function module.awawa()"