My admin commands split on a " "/space so it just doesnt show my whole message
I have tried changing its value it never worked I tried youtube.com and devforum.roblox.com I did not find any solutions.
I need my gui to work but when I say my message it only says the first word because it splits on a space so It will not say the whole message. (Sorry for not much detail)
local commands = {}
local cmd
--local CommandsModule = require(script.Parent.CommandsModule)
local ClientCommand = game.ReplicatedStorage: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)
cmd = "msg"
local message = args[1]
if message then
ClientCommand:FireAllClients(message,cmd)
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
commands[cmdName](player,args)
end
end
end)
end)
Tip: mentioning users to try to help you isn’t gonna get you anywhere, they’ll just ignore your post.
Now to help with your post, I made it a little easier to get the message:
local prefix = ":" -- the prefix
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if string.sub(message,1,1) == prefix then -- if there is a prefix
if string.sub(message,2,2) == "m" then
print(string.sub(message,4,string.len(message))) -- prints the message
end
end
end)
end)
local commandsModule = {}
--local BodyForce
--local cmd
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 space = string.find(" ",result)
if space then
result[space] = "-"
end
local messageClone = messageGui:Clone()
messageClone.Parent = player:WaitForChild("PlayerGui")
result[space] = " "
messageClone.MessageFrame.Message.Text = tostring(result)
local image = game.Players:GetUserThumbnailAsync(player.UserId, Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size100x100)
messageClone.MessageFrame.PlayerImage.Image = image
print("Message Sent Successfully")
wait(5)
messageClone:Destroy()
end
--[[
function commandsModule.KeyPress(player)
cmd = "fly"
local UIS = game:GetService("UserInputService")
local MovesetKeys = {
Enum.KeyCode.A, --This would be left
Enum.KeyCode.D, --Right
Enum.KeyCode.W, --Forwards
Enum.KeyCode.S --Backwards
}
local CurrentKeyHit = nil --There's no current key set
UIS.InputBegan:Connect(function(Input, Chatted)
if Chatted then
return
end
if table.find(MovesetKeys, Input.KeyCode) then
if Input.KeyCode == MovesetKeys[1] then
CurrentKeyHit = "Left"
elseif Input.KeyCode == MovesetKeys[2] then
CurrentKeyHit = "Right"
elseif Input.KeyCode == MovesetKeys[3] then
CurrentKeyHit = "Forwards"
elseif Input.KeyCode == MovesetKeys[4] then
CurrentKeyHit = "Backwards"
else
CurrentKeyHit = nil
end
game.ReplicatedStorage.ServerCommand:FireServer(CurrentKeyHit,cmd)
end
end)
end
function commandsModule.FlyCommand(player,key)
local Char = player.Character
if Char.HumanoidRootPart:FindFirstChild("BodyForce") then
BodyForce = Char.HumanoidRootPart.BodyForce
else
local Force = Instance.new("BodyForce")
Force.Parent = Char.HumanoidRootPart
BodyForce = Force
end
if key == "Left" then
BodyForce.Force = Char.HumanoidRootPart.RightVector * -25
elseif key == "Right" then
BodyForce.Force = Char.HumanoidRootPart.RightVector * 25
elseif key == "Forwards" then
BodyForce.Force = Char.HumanoidRootPart.LookVector * 25
elseif key == "Backwards" then
BodyForce.Force = Char.HumanoidRootPart.LookVector * -25
end
end
function commandsModule.UnflyCommand()
BodyForce:Destroy()
end]]
return commandsModule