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

attempt to concatenate local 's' (a table value)?

Asked by 5 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

I am trying to set a value to something a player said

Here is my sad failed localscript

localscript:

P.Chatted:Connect(function(msg)
 local s = string
 if msg == ":add "..s then
 MapVal.Value = s
 end
end)
0
What is "string" supposed to be? green271 635 — 5y
0
a string that the player says. mixgingengerina10 223 — 5y

1 answer

Log in to vote
1
Answered by
jaschutte 324 Moderation Voter
5 years ago
Edited 5 years ago

Without the quotes, 'string' isn't a string. To fix your code simply add quotes around the word string

P.Chatted:Connect(function(msg)
 local s = "string"
 if msg == ":add "..s then
 MapVal.Value = s
 end
end)

This code SHOULD add a value that the player typed:

P.Chatted:Connect(function(msg)
    local command = ":add "
    if string.sub(msg, 1, string.len(command)) == command then
        local addValue = string.sub(msg, string.len(command))
        MapVal.Value = addValue
    end
end)

-I didn't test it, if there are errors message me.

Ad

Answer this question