Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Attempt to concatenate '?' (a nil value) ??

So i got this error on one of the line of my server script

Error Line: Line 39, requested by @incapaxian

Script(Look for command lines like " -- ** ") :

local Mic = script.Parent
local StringValue = Mic:WaitForChild("StringValue") -- **
local BoolValue = Mic:WaitForChild("BoolValue")
local tables = {} -- **
local sender = "" -- **
local recipient = "" -- **
BoolValue.Value = false -- ClickDetector Not Clicked
print(BoolValue.Value)

game.Players.PlayerAdded:Connect(function(player)
	Mic.ClickDetector.MouseClick:Connect(function()
		
		if BoolValue.Value == false and workspace.Radio2.Mic:WaitForChild("StringValue").Value ~= player.Name then
			Mic.Sound:Play()
			print("Played")
			Mic.BillboardGui:WaitForChild("TextLabel1").Visible = true
			StringValue.Value = player.Name -- ** <--<--<-- One Here
			print("StringValue.Value = "..StringValue.Value)
			BoolValue.Value = true
			print(BoolValue.Value)
		else
			return
		end
		
		if BoolValue.Value == true then
			print("Stage1")
			if workspace.Radio2.Mic.StringValue.Value ~= "" then
				print("Stage2")	
				player.Chatted:Connect(function(message) -- **
					print("MessageID Is "..player.UserId)
					if not player.Name then
						print("Did not print what "..player.Name.." said.")
						return
					elseif Mic:WaitForChild("StringValue").Value == player.Name then
						
						tables[sender] = Mic.StringValue.Value -- **
						tables[recipient] = workspace.Radio2.Mic.StringValue.Value -- ** <--<--<-- One Here
						print("Recipient Is "..recipient)
						script.Parent.Parent.Parent.Radio2.Mic.BillboardGui.TextLabel2.Text = "["..player.Name.."]: "..message[tostring(tables[sender])] -- Error Line
						print("Done")
						wait(5)
						script.Parent.Parent.Parent.Radio2.Mic.BillboardGui.TextLabel2.Text = ""
				
					end		
				end)
			else
				print("Not Stage2")
				BoolValue.Value = false
				print(BoolValue.Value)
				return
			end
			
		else
			
			BoolValue.Value = false
			print(BoolValue.Value)
			return
			
		end
	end)
end)

Error: Attempt to concatenate '?' (a nil value)

Can someone explain to me why i got this error? And how can i change the error line so that i wont get the error ?

All helps will be greatly appreciated. Will accept the most suitable answer.

43 comments

0

"Look for command lines like --" First those aren't commands, and you have 50 lines with --

0

ok, first state which line is erroring, you have multiple lines in your code where you're trying to concatenate

0

also, click detectors have a player parameter

0

@theking48989987 Look for the line that says -- Error Line

0

We don't need to look through it ourselves, tell in the question goddamn it

0

@incapaxian Stupid so why are u giving downvotes? ill report ur account for anyhow giving downvotes and this is not a request, and its not against any rule, ill report u just for that idiot.

0

@incapaxian and those are commands, and "--" this is command stuff to it so that those who were trying to help can see the main point better unlike u anyhow giving downvotes

2

I'm downvoting because it is a bad question, and you're refusing to make it easier for us to see the line of error, all you say is to look for a line -- Error Line, when you can just say in the question where, like "The error occurs on line X".

0

thats called two dashes and it is also a comment

0

Makes it way easier and -- is for single line comments, not a command whatsoever

0

@incapaxian How is it a bad qn? i bet u dont even know what causes that error. And what do u mean just say in the question? I can also say it using commands right? Whats the problem?

0

I can remove my downvote if the question is more descriptive

0

Commands is the improper terminology

0

its comments, not commands, those are very different things

0

@incapaxian scroll down theres more lol. And i dont even understand what is causing the error so how am i gonna make it more descriptive

0

I never said that at all. I meant you should put in your question where the error is, not just tell us to read 61 lines of messy code only to find the line that is commented "Error Here". We don't need to be doing the searching at all

0

@theking48949987 oo lol im confused with the other programming language

0

@incapaxian Ok so? Find ONE post and send me the link and show me if anybody actually did that. I didnt see before, also i didnt use scriptinghelpers alot, how the heck am i suppose to know these? go ahead send me link

0

In short, tell us where it is, not what it is.

0

what did this get -1 for

0

OMg Yokohane just tell which line is the error at. It should say it next to the error. Otherwise we won't be able to help -.-

0

@incapaxian Ok reported for that.

0

@Kiriot22 Just did, and i didnt see anybody who did that before

1

removed my downvote, this is all i told you to do lmao

1

Hm. Why are you trying to use the message variable like a table? It's a string

0

@incapaxian https://scriptinghelpers.org/questions/72415/i-got-this-tostring-error-not-what-i-expected-it-to-be-anybody-can-help-urgent, and now u assume that qns with [URGENT] are bad qns, if u dont wanna help just dont do anything, i dont even care if u give downvote dude, all i care about is that u anyhow give it -_-.

0

@Kiriot22 ok so how do i make it as a string, i mean someone sent me a link that explains how to index strings. but dont quite get it

0

they are bad questions. Questions with URGENT in the title are bad questions. There is absolutely no reason to put that in your titles

0

@incapaxian No what do u mean? Ill give u an example. Sometimes people are doing projects for someone and the deadlines is getting close, then why cant people put [URGENT] in it?

0

deadline*

0

You never explained what you want your script to do. Im unsure what you want to do with the message.

0

Bad excuse, and why are they doing commissions for people if they can't solve their issue? You just look desperate and impatient doing that

0

@Kiriot22 i only want an explanation of why this happen dude, as i said in the post

0

The only non nil values for strings are find, gsub, match, gmatch, sub, reverse, len, format, char, byte, and a few more

0

@incapaxian Ok then what if u cant solve something and u are about to travel in a few days and the country u go has no wifi and u really want to get it done cause u dont wanna come back and forget* everything?

0

@incapaxian What do u mean by non nil values

0

I already told you why it happens. It happens because you use a string like a table.

0

@Kiriot22 oo ok then how do i change it to string?

0

tostring()

0

@gioni01 thats what i did dude

0

@incapaxian i just want u to know this. scriptinghelpers.org is for people to ask and answer qns about scripting, its not a website for u to judge if the qn is bad or good. And if u are lazy to read and know whats going on, just dont, simple. U know what u are doing when u are anyhow giving downvotes just by u thinking oh this qn is "bad"? U are F-ing abusing the power to give downvotes.

0

@incapaxian And u know what are downvotes for? Its for questions that are against the rule and more, but not for ur personal opinion and judgement. And if u continue to do so, i can guarantee that u will not only get reported by me.

0

Downvotes exist to rate the quality of a question or answer, so it's not abusing, lol

1 answer

You are indexing message as if it were a table, but it's a string - that is what is giving you the nil value, which is why you're getting the error message. script.Parent.Parent.Parent.Radio2.Mic.BillboardGui.TextLabel2.Text = "["..player.Name.."]: "..message should work.

This discussion is preserved as it was. New answers, comments, and votes are closed.