Hi, I am trying to make it so if you for example say "/explode iiLevelMaker" it will explode the player they mentioned.
I tried using message:sub, but it didn't work or I didn't use it the right way.
Here is the script:
repeat wait() until game.Players.LocalPlayer.Character
local Player = game.Players.LocalPlayer
local Players = game.Players
local Keys = game:GetService("ReplicatedStorage").Keys
local Doors = workspace.RoomDoors
local Char = Player.Character
local GroupID = 4394811
local MinRank = 3
local AllRooms = {"Room 1","Room 2","Room 3","Room 4","Room 5","Room 6","Room 7","Room 8","Room 9","Room 10","Room 11","Room 12","Room 13","Room 14","Room 15","Room 16","Room 17","Room 18","Room 19","Room 20","Room 21","Room 22","Room 23","Room 24","Room 25","Room 26","Room 27","Room 28","Room 29","Room 30"}
Player.Chatted:Connect(function(message)
if Player:GetRankInGroup(GroupID) >= MinRank then
for i,v in pairs(AllRooms) do -- Get All Rooms
local GetTargetFromArgument = message:sub(2) -- Get Player object from argument
local Target = Players:FindFirstChild(GetTargetFromArgument) -- Find that player that was mentioned in the chat argument.
print(Target.Name) -- Printing the target's name.
end
end
end)
Error: "16:05:18.765 - Players.iiLevelMaker.PlayerGui.DoorSystem_CLIENT:16: attempt to index local 'Target' (a nil value)"

1 comment
Because the target wasn't found.