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

Getting a players chat string value?

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)

2 comments

0

ALSO, it's not in a local script, it's in a normal one.

0

This is in a gui right?

1 answer

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)

1 comment

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.

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