Nope didnt work
Try printing the args before the line commands[cmdName](player,args)
. Tell me what was outputted.
this is what was printed:
there you see now
I changed it to local cmdName = cmd[2] and now it prints
but shows the x1 x2 etc.
So cmd[2] works
It may not get the player and plus it only gets one I want to get all players in this:
function commandsModule.FindPlayer()
for _, player in pairs(game.Players:GetPlayers()) do
return player
end
end
And my command just will not get past FireAllClients
I will show all of my new scripts I changed all of them except one
--script
local commands = {}
--local CommandsModule = require(script.Parent.CommandsModule)
local admins = {
"FreeFlyHaker56"
}
local prefix = ":"
local function findPlayer(name)
for i, player in pairs(game.Players:GetPlayers()) do
if string.lower(player.Name) == name then
return player
end
end
return nil
end
local function isAdmin(player)
for _, v in pairs(admins) do
if v == player.Name then -- If their an admin
return true
end
end
return false
end
commands.m = function(sender, args)
local message = args[1]
if message then
for _, player in pairs(game.Players:GetPlayers()) do
script.Parent.ClientCommand:FireAllClients(player, message)
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message,recipient)
if isAdmin(player) then
message = string.lower(message)
local splitString = message:split(" ")
local slashCommand = splitString[1]
local cmd = slashCommand:split(prefix)
local cmdName = cmd[2]
if commands[cmdName] then
local args = {}
for i = 2, #splitString, 1 do
table.insert(args,splitString[i])
end
print(commands[cmdName](player,args))
commands[cmdName](player,args)
end
end
end)
end)
--localscript
local CommandsModule = require(script.Parent.CommandsModule)
script.Parent:WaitForChild("ClientCommand").OnClientEvent:Connect(function(player, msg)
CommandsModule.MessageCommand(player, msg)
end)
--modulescript
local commandsModule = {}
function commandsModule.FindPlayer()
for _, player in pairs(game.Players:GetPlayers()) do
return player
end
end
function commandsModule.MessageCommand(player, result)
local messageGui = script.MessageGui
local messageClone = messageGui:Clone()
messageClone.Parent = player:WaitForChild("PlayerGui")
messageClone.MessageFrame.Message.Text = tostring(result)
end
return commandsModule
Please work… If it doesn’t just tell me what is outputted.
--script
local commands = {}
--local CommandsModule = require(script.Parent.CommandsModule)
local admins = {
"FreeFlyHaker56"
}
local prefix = ":"
local function findPlayer(name)
for i, player in pairs(game.Players:GetPlayers()) do
if string.lower(player.Name) == name then
return player
end
end
return nil
end
local function isAdmin(player)
if table.find(admins,player.Name) then
return true
end
return false
end
commands.m = function(sender, args)
local message = args[1]
if message then
print("Message Found")
script.Parent.ClientCommand:FireAllClients(message)
end
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message,recipient)
if isAdmin(player) then
message = string.lower(message)
local splitString = message:split(" ")
local slashCommand = splitString[1]
local cmd = slashCommand:split(prefix)
local cmdName = cmd[2]
if commands[cmdName] then
print("Found Function")
local args = {}
for i = 2, #splitString, 1 do
table.insert(args,splitString[i])
end
print("Running Function")
print(args) -- Arguments
commands[cmdName](player,args)
end
end
end)
end)
--localscript
local CommandsModule = require(script.Parent.CommandsModule)
local player = game.Players.LocalPlayer
script.Parent:WaitForChild("ClientCommand").OnClientEvent:Connect(function(msg)
CommandsModule.MessageCommand(player, msg)
end)
--modulescript
local commandsModule = {}
function commandsModule.FindPlayer()
for _, player in pairs(game.Players:GetPlayers()) do
return player
end
end
function commandsModule.MessageCommand(player, result)
local messageGui = script.MessageGui
local messageClone = messageGui:Clone()
messageClone.Parent = player:WaitForChild("PlayerGui")
messageClone.MessageFrame.Message.Text = tostring(result)
print("Message Sent Successfully")
end
return commandsModule
It did not summon in the gui for me
The message did not send whatsoever
I’m now thinking is it because your remote event couldn’t be found? Can you show me your studio hierarchy of where all your scripts and remote events are?
ok bro why not
Ignore the model name it is a meme ok
I know how to spell lol
How about for the remote event in your server script define it with a WaitForChild at the top of the script. Like this:
local commands = {}
--local CommandsModule = require(script.Parent.CommandsModule)
local ClientCommand = script.Parent:WaitForChild("ClientCommand")
local admins = {
"FreeFlyHaker56"
}
local prefix = ":"
local function findPlayer(name)
for i, player in pairs(game.Players:GetPlayers()) do
if string.lower(player.Name) == name then
return player
end
end
return nil
end
local function isAdmin(player)
if table.find(admins,player.Name) then
return true
end
return false
end
commands.m = function(sender, args)
local message = args[1]
if message then
print("Message Found")
ClientCommand:FireAllClients(message)
print("Remote Event Fired")
end
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message,recipient)
if isAdmin(player) then
message = string.lower(message)
local splitString = message:split(" ")
local slashCommand = splitString[1]
local cmd = slashCommand:split(prefix)
local cmdName = cmd[2]
if commands[cmdName] then
print("Found Function")
local args = {}
for i = 2, #splitString, 1 do
table.insert(args,splitString[i])
end
print("Running Function")
print(args) -- Arguments
commands[cmdName](player,args)
end
end
end)
end)
Still didnt print message sent
printed the same thing as before
For your local script try adding a print to see if the remote event fired successfully:
local CommandsModule = require(script.Parent.CommandsModule)
local player = game.Players.LocalPlayer
script.Parent:WaitForChild("ClientCommand").OnClientEvent:Connect(function(msg)
print("Remote Event Fired To The Client")
CommandsModule.MessageCommand(player, msg)
end)
It was not fired it never passed the fireallclients