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
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)