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

how do i reference a players name in a string?

local Admins = {["sonichfan"] = true,["mattbitz13"] = true,["xXlegenmaster"] = true}

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if string.find(string.lower(msg), string.lower("ez")) or string.find(string.lower(msg), string.lower("your bad")) then
			plr.Character.Humanoid.Health = 0
			game.StarterGui:SetCore("ChartMakeSystemMessage", {
				
				Text = "Dont be toxic,", --Here, im trying to make it so that you can reference the players name, if i try to do plr.Name outside the string it wont work ill get an error, if i put it inside ittl just say plr.Name
				Font = Enum.Font.Antique,
				Color = Color3.fromRGB(255,200,0),
				FontSize = Enum.FontSize.Size96
				
			})
		end
	end)
end)

1 answer

✓ Accepted answer

for line 9, you will wanna use the ".." operator. So at line 9, you do this:

Text = "Don't be toxic, "..plr.Name.."." -- I also corrected some grammar issues lol

4 comments

0

also, i suggest you use userids instead of usernames. It is a bit more work, but will be quite useful (because if the person changes username, you have to go edit the script which can be kind of annoying, however the userid will stay the same when player change name so if you use userids, you won't have to change it later on)

0

^ This

0

As well as not having to modify usernames everytime they change the new display names might also break some things (But I don't really know)

0

actually display names won't, because display names use a seperate property in the player.

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