Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] Line 29: bad argument #3 to Value (string expected, got nil) in my script, what's going on?

Asked by 5 years ago
Edited 5 years ago

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.

0
use lua brackets DinozCreates 1070 — 5y
0
how? BenjySmb 16 — 5y
0
edit your question, click the blue Lua button then the 2 rows of squigglies need to surround the code DinozCreates 1070 — 5y
0
Edi:- code block. User#5423 17 — 5y
View all comments (3 more)
0
Done BenjySmb 16 — 5y
0
which line is 29? its just an end here DinozCreates 1070 — 5y
0
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. DinozCreates 1070 — 5y

Answer this question