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

Getting a players chat string value?

Asked by
lucas4114 607 Moderation Voter
9 years ago

So, I'm try to make something.. Yes something, and for it I need to get the value of what the player says, I tryed stuff from the wiki and made this and it... Doesn't work. :/

function playerjoins(Player)
    Player.Chatted:connect(message)
end

function message(msg)
    local text = Instance.new ("StringValue")
    text.Parent = script
    text.Value = msg
    script.Parent.Text = text.Value
end

game.Players.PlayerAdded:connect(playerjoins)
0
ALSO, it's not in a local script, it's in a normal one. lucas4114 607 — 9y
0
This is in a gui right? woodengop 1134 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Too many functions... and remember to pass the msg to the message function as a parameter. If you wish to keep your format of script then on line 2 change it to -- Player.Chatted:connect(message(msg)) <- lmk if this doesn't work, I may have it wrong, but I would say the below method is much easier than a bunch of functions spread out

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
-- here you do stuff with the message, you can do things like
-- if msg == "hello" then
-- to get a lowercase version of the msg simply create a new variable
--lower = string.lower(msg)
--This is where you would to the string value thing your trying to work out
    end)
end)

0
Nice answer but you should suggest why he shouldn't use a lot of functions and include what he wants to do in there. If I were you, I'd also advise him of an easier solution to his problem, I would just do script.Parent.Text = msg instead of making a string value and setting the text to it's value. Spongocardo 1991 — 9y
Ad

Answer this question