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

Attempt to concatenate '?' (a nil value) ?? [closed]

Asked by 5 years ago
Edited 5 years ago

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.

0
"Look for command lines like --**" First those aren't commands, and you have 50 lines with --** User#24403 69 — 5y
0
ok, first state which line is erroring, you have multiple lines in your code where you're trying to concatenate theking48989987 2147 — 5y
0
also, click detectors have a player parameter theking48989987 2147 — 5y
0
@theking48989987 Look for the line that says -- Error Line Yokohane 50 — 5y
View all comments (39 more)
0
We don't need to look through it ourselves, tell in the question goddamn it User#24403 69 — 5y
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. Yokohane 50 — 5y
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 Yokohane 50 — 5y
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". User#24403 69 — 5y
0
thats called two dashes and it is also a comment theking48989987 2147 — 5y
0
Makes it way easier and -- is for single line comments, not a command whatsoever User#24403 69 — 5y
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? Yokohane 50 — 5y
0
I can remove my downvote if the question is more descriptive User#24403 69 — 5y
0
Commands is the improper terminology User#24403 69 — 5y
0
its comments, not commands, those are very different things theking48989987 2147 — 5y
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 Yokohane 50 — 5y
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 User#24403 69 — 5y
0
@theking48949987 oo lol im confused with the other programming language Yokohane 50 — 5y
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 Yokohane 50 — 5y
0
In short, tell us where it is, not what it is. User#24403 69 — 5y
0
what did this get -1 for LoganboyInCO 150 — 5y
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 -.- Amiaa16 3227 — 5y
0
@incapaxian Ok reported for that. Yokohane 50 — 5y
0
@Kiriot22 Just did, and i didnt see anybody who did that before Yokohane 50 — 5y
1
removed my downvote, this is all i told you to do lmao User#24403 69 — 5y
1
Hm. Why are you trying to use the message variable like a table? It's a string Amiaa16 3227 — 5y
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 -_-. Yokohane 50 — 5y
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 Yokohane 50 — 5y
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 User#24403 69 — 5y
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? Yokohane 50 — 5y
0
deadline* Yokohane 50 — 5y
0
You never explained what you want your script to do. Im unsure what you want to do with the message. Amiaa16 3227 — 5y
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 User#24403 69 — 5y
0
@Kiriot22 i only want an explanation of why this happen dude, as i said in the post Yokohane 50 — 5y
0
The only non nil values for strings are find, gsub, match, gmatch, sub, reverse, len, format, char, byte, and a few more User#24403 69 — 5y
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? Yokohane 50 — 5y
0
@incapaxian What do u mean by non nil values Yokohane 50 — 5y
0
I already told you why it happens. It happens because you use a string like a table. Amiaa16 3227 — 5y
0
@Kiriot22 oo ok then how do i change it to string? Yokohane 50 — 5y
0
tostring() Gey4Jesus69 2705 — 5y
0
@gioni01 thats what i did dude Yokohane 50 — 5y
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. Yokohane 50 — 5y
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. Yokohane 50 — 5y
0
Downvotes exist to rate the quality of a question or answer, so it's not abusing, lol User#24403 69 — 5y

Locked by User#24403 and RubenKan

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 5 years ago

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.

Ad