My require script does not work

I am making a require script. But it not work. Please help me to fix it.

Here is the model.

Here are the Explorer and Scripts.

Explorer

螢幕擷取畫面 2021-02-17 033235

Script:(MainModule)
local module = {}

function module.load(target)
	local Cloned_Events = script.Events:Clone()
	Cloned_Events.Parent = game.ReplicatedStorage
	
	local Clone_SystemMessage = script["System Message"]:Clone()
	local Clone_PlayerChatted = script.PlayerChatted:Clone()
	
	for _,v in pairs(game.Players:GetChildren()) do
		Clone_SystemMessage:Clone().Parent = v.PlayerGui
		Clone_PlayerChatted:Clone().Parent = v.PlayerGui
	end
end

return module
(System Message)
local systemMsgRE = game.ReplicatedStorage:WaitForChild("CreateSystemMessage")

systemMsgRE.OnClientEvent:Connect(function(systemMsg)

	game.StarterGui:SetCore("ChatMakeSystemMessage", {
		Text = systemMsg,
		Color = Color3.fromRGB(255, 115, 0),
		Font = Enum.Font.SourceSansBold,
		TextSize = 18,
	})
end)
(VoteKick)
local votekickCmd = "/VoteKick"

local cooldown = 60
local plrsOnCooldown = {}

local timeForVote = 10

local isVotingForKick = false
local plrsVoted = {}

local votesForKick = 0

local systemMsgRE = game.ReplicatedStorage.Events:WaitForChild("CreateSystemMessage")


game.ReplicatedStorage.Events.PlayerChatted.OnServerEvent:Connect(function(plr, msg)

		if string.sub(msg, 1, string.len(votekickCmd)) == votekickCmd and not isVotingForKick then

			local plrVoted = game.Players:FindFirstChild(string.sub(msg, string.len(votekickCmd) + 2))

			if plrVoted and not plrsOnCooldown[plr] then

				plrsOnCooldown[plr] = true

				isVotingForKick = true
				votesForKick = 0

				systemMsgRE:FireAllClients("[VOTEKICK] Type 'yes' to vote for " .. plrVoted.Name .. " to be kicked. Type 'no' to ignore the vote. You gave".. timeForVote.. "sec to voting.")

				wait(timeForVote)

				isVotingForKick = false

			if votesForKick >= math.ceil(#game.Players:GetPlayers()/2) then
				plrVoted:Kick("You have been votekicked") 
				systemMsgRE:FireAllClients("[VOTEKICK]".. plrVoted.. "votekicked")
			end

				wait(cooldown - timeForVote)
				plrsOnCooldown[plr] = nil
			end

		elseif isVotingForKick then

			if msg == "yes" then

				if plrsVoted[plr] ~= "yes" then

					votesForKick = votesForKick + 1
				end
				plrsVoted[plr] = "yes"

			elseif msg == "no" then

				if plrsVoted[plr] == "yes" then

					votesForKick = votesForKick - 1
				end
				plrsVoted[plr] = "no"
			end		
		end	
end)
(PlayerChatted)
game.Players.LocalPlayer.Chatted:Connect(function(msg)

game.ReplicatedStorage.Events.PlayerChatted:FireServer(msg)

end)

What are you trying to script here?

I just want to use require().load("")

oh… so you want to require the module like require(ID Here).Parent = script.Parent so in your case
require(6404041000).Parent = script.Parent (module has to be on copyable or it wont work… yours is already like that so you are fine.) make sure the script is in the model you want the module to be in.

The script is work now, but it has an error.

Infinite yield possible on 'ReplicatedStorage:WaitForChild("CreateSystemMessage")

Have you tested it on the model/thing you where gonna use it on?

I tested the scripts(Script and Local Script)
It has the same error too. :frowning:

What model are you testing it on? what’s it about? am I able to test it?

I tested the System Message, VoteKick and PlayerChatted scripts.
Scripts are on the top.
I put them in the correct parent.

I’m a bit confused, it seems as though your scripts don’t actually require your module? Perhaps they need to be updated?

EDIT: Sorry, misread this, it seems as though you need to type in this instead:

ReplicatedStorage.Events:WaitForChild("CreateSystemMessage")
1 Like

That’s the point I was getting into… Because I did not know what he was trying to acquire and what the model was for. Now he doesn’t even need to acquire it.

1 Like

I want to use server command to load scripts.

Sorry, I made a mistake, please re-read this :slightly_smiling_face:

1 Like

I found the error.
But I have another error:

OnClientEvent can only be used on the client
I know how to fix it. Thank you guys

1 Like

You are welcome, your also lucky I learned it too because if I didn’t learn it about a month ago then I wouldn’t be here XD I made a donation board for others to use, that’s why I was asking what you where using it for.

2 Likes