I am trying to make a room give script where you say 'give PLAYER room NUMBER' and it keeps saying this, Line 29: bad argument #3 to Value (string expected, got nil)
Here's the script:
Ok = BrickColor.new("Lime green")
Ta = BrickColor.new("Really red")
gid = 4548562
gr = 7
game.Players.PlayerAdded:Connect(function(Player)
if Player:GetRankInGroup(gid) >= gr then
Player.Chatted:Connect(function(msg)
local args = {}
for arg in string.gmatch(msg, "[^, ]+") do
table.insert(args, arg)
end
if args[1] == "give" then
local TargetPlayer = args[2]
if TargetPlayer and game.Players[TargetPlayer] ~= nil then
local plr = game.Players[TargetPlayer]
if plr then
local RoomType = args[3]
if RoomType then
if RoomType == "room" then
local RoomNumber = args[4]
if RoomNumber then
-- Giving a normal Room: current variables are TargetPlayer, RoomNumber
game.ServerStorage.RoomCards[RoomNumber]:Clone().Parent = game.Players[TargetPlayer].PlayerGui
game.ReplicatedStorage.RoomDatabase.Standard[RoomNumber].Owner.Value = TargetPlayer.Name
game.Workspace.Manage.SurfaceGui.Rooms[RoomNumber].BackgrouncColor3 = Ta
game.Workspace.Manage.SurfaceGui.Rooms[RoomNumber].N1.Text = TargetPlayer.Name
end
elseif RoomType == "suite" then
local RoomNumber = args[4]
if RoomNumber then
-- Giving a Suite: current variables are TargetPlayer, RoomNumber
game.ServerStorage.SuiteCards[RoomNumber]:Clone().Parent = game.Players[TargetPlayer].PlayerGui
game.ReplicatedStorage.RoomDatabase.Suites[RoomNumber].Owner.Value = TargetPlayer.Name
game.Workspace.Manage.SurfaceGui.Rooms[RoomNumber].BackgrouncColor3 = Ta
game.Workspace.Manage.SurfaceGui.Rooms[RoomNumber.."S"].N1.Text = TargetPlayer.Name
end
end
end
end
end
end
end)
end
end)
If anybody has any ideas please let me know.

7 comments
use lua brackets
how?
edit your question, click the blue Lua button then the 2 rows of squigglies need to surround the code
Edi:- code block.
Done
which line is 29? its just an end here
also why arent you using locals? there are a lot of situations here where you could combine if statements for a lot more efficiency, and more importantly to clean this nasty code up.