I have done many changes, and have conducted many tests, but when I try to enter a command [run/object], the code will not execute the command, and I have tried 2-3 different coding methods to try and get it working, but all have failed, sadly I can't provide any Output because there is no Output showing up, I don't know what I am doing wrong in the code, but I can't see what I did wrong, here is the script;
wait(.5) local GroupAdmins = {"TheeDeathCaster","Player1"} local GroupId = 000000 local Hint = true function ChkAdmin(plr) for i = 1, #GroupAdmins do if plr:lower() == GroupAdmins[i]:lower() then return true end end return false end function Statz(plr) if plr then print(plr.Name.." has joined the Training Facility") end local Stat = Instance.new("BoolValue",plr) Stat.Name = "leaderstats" Stat.Value = true local Rank = Instance.new("StringValue",Stat) Rank.Name = "Rank" if plr:IsInGroup(GroupId) then Rank.Value = plr:GetRoleInGroup(GroupId) elseif not plr:IsInGroup(GroupId) then Rank.Value = "Unknown" end end function GetPlr(plr,str) local plrz = {} if str:lower() == "me" then table.insert(plrz,plr) else for i,v in pairs(game.Players:GetPlayers()) do if str ~= "" and v and v.Name:lower():find(str:lower()) == 1 then table.insert(plrz,v) end end end return plrz end function Hintz(plr) if Hint and script:FindFirstChild("Hint") and plr and plr:FindFirstChild("PlayerGui") then Hints = script.Hint:Clone() Hints.Parent = plr.PlayerGui end end function Message(msg,plrz) for i,v in pairs(plrz) do coroutine.wrap(function() if v and v:FindFirstChild("PlayerGui") then local M = Instance.new("Message",v.PlayerGui) for x = 1, #msg do M.Text = msg:sub(1,x) wait(1/19) end wait(#msg/19+2.5) if M then return M:Destroy(), print("Message done") end end end)() end end local Sword = script:WaitForChild("Sword"):Clone(); local SWORDS = {}; local MAPS = {}; local DOORS = {}; for i,v in pairs(game.Workspace:GetChildren()) do if v and v.Name:lower():find("door") then table.insert(DOORS,v) end end print(#DOORS," Doors") function Cmds(plr,msg) if msg:lower() == "test" then Message("Test completed, working! :D",{plr}) end if not ChkAdmin(plr.Name) then return end if msg:lower():sub(1,2) == "m/" then Message(plr.Name..": "..msg:sub(3),game.Players:GetPlayers()) end if msg:lower(1,5) == "open/" then for i,v in pairs(game.Workspace:GetChildren()) do --I have also tried the table 'DOORS', but that didn't work either [open/Door1] coroutine.wrap(function() if v and v:IsA("BasePart") and v.Name:lower() == msg:lower():sub(6) then v.Transparency = 0.2 v.CanCollide = false end end)() end end if msg:lower(1,6) == "close/" then for i,v in pairs(game.Workspace:GetChildren()) do coroutine.wrap(function() if v and v:IsA("BasePart") and v.Name:lower() == msg:lower():sub(7) then v.Transparency = 0 v.CanCollide = true end end)() end end if msg:lower(1,6) == "sword/" then --I have tried 'sword/thee', and 'sword/me', but it will not work local plrz = GetPlr(plr,msg:lower():sub(7)) for i,v in pairs(plrz) do coroutine.wrap(function() if v and v:FindFirstChild("Backpack") and v.Character and v.Character:FindFirstChild("Humanoid") then local GiveSword = Sword:Clone() GiveSword.Parent = v.Backpack GiveSword.Name = v.Name.."'s Sword" table.insert(SWORDS,GiveSword) Instance.new("BoolValue",v).Name = "FIGHT" wait(.5) v.Character.Humanoid:EquipTool(GiveSword) end end)() end end if msg:lower(1,8) == "unsword/" then local plrz = GetPlr(plr,msg:lower():sub(9)) for i2,v2 in pairs(plrz) do coroutine.wrap(function() for i,v in pairs(SWORDS) do if v and v.Name:lower() == v2.Name.."'s Sword" then v:Destroy() end end for i,v in pairs(v2:GetChildren()) do if v and v.Name == "FIGHT" then v:Destroy() end end end)() end end if msg:lower(1,4) == "run/" then --I've used the command correctly, and typed the Object name correctly aswell, but it won't execute if not game:GetService("Lighting") then return false, print("Lighting does not exist!") end for i,v in pairs(MAPS) do if v then v:Destroy() end end for i,v in pairs(game:GetService("Lighting"):GetChildren()) do if v and v.Name:lower() == msg:lower():sub(5) then --I typed the name correctly, but it won't execute local MAP = v:Clone() table.insert(MAPS,MAP) MAP.Parent = game.Workspace MAP:MakeJoints() end end end if msg:lower() == "stop/" then for i,v in pairs(MAPS) do if v then v:Destroy() end end end end function Control(plr) print(plr.Name.." has joined the server") coroutine.wrap(function() if plr.userId == game.CreatorId then table.insert(GroupAdmins,plr.Name) end end)() coroutine.wrap(function() if (ChkAdmin(plr.Name)) then print(plr.Name.." is an Admin!") Message("You're an Admin!",{plr}) end end)() coroutine.wrap(function() if plr then Statz(plr) plr.CharacterAdded:connect(function() Hintz(plr) end) end end)() plr.Chatted:connect(function(msg) Cmds(plr,msg) end) end for i,v in pairs(game.Players:GetPlayers()) do Control(v) end game.Players.PlayerAdded:connect(Control)
I am sorry if this Question is considered Off-Topic
, or Too Board
.
So, the problem with your script.. get ready to facepalm(:
Line 70: if msg:lower(1,5) == "open/" then
Line 81: if msg:lower(1,6) == "close/" then
Line 92: if msg:lower(1,6) == "sword/" then
etc..
See what's wrong in all of those lines? You're trying to use the string.sub arguments with a string.lower method. On line 66 you got it correct,
if msg:lower():sub(1,2) == "m/" then
Also, you're never calling the 'Cmds' function. Make sure that you make a connection statement for that.
I can't revise your whole script because of how you setup your functions, so you're going to have to do that.. but i'll give you a sort of guideline code so that you can revise this script yourself(:
--Use a dictionary to define your functions(; local commands = { ["kill"] = function(str) local plr for i,v in pairs(game.Players:GetPlayers()) do if v.Name:lower():match(str:lower()) then plr = v end end plr.Character:BreakJoints() end, ["msg"] = function(str) local m = Instance.new("Message",game.Workspace) m.Text = str wait(3) m:Destroy() end } game.Players.LocalPlayer.Chatted:connect(function(msg) for i,v in pairs(commands) do if msg:lower():sub(1,i:len()) == i then local str = msg:sub(i:len() + 2) v(str) end end end)
You can read more about dictionaries here.