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

[ANS] How to add spaces to messages?

So I'm making a webhook that posts if someone was temporarily banned for exploiting, and my code works, except that there is no space between the username and the message. I thought the way to do this was ".." but it doesn't seem to be working.

Code:

local url = "my url but not included here"
local http = game:GetService("HttpService")


game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		local newmsg = plr.Name .. "was temporarily banned for exploiting from CUBE Sim" --not working
		local data = {
			["username"] = "Exploit Alert",
			["content"] = newmsg
		}
		local newdata = http:JSONEncode(data)
		http:PostAsync(url, newdata)
	end)
end)

New code:

local url = "my url but not included here"
local http = game:GetService("HttpService")


game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		local name = plr.Name
		local smsg = " was temporarily banned for exploiting in CUBE Sim"
		local newmsg = name .. smsg
		local data = {
			["username"] = "Exploit Alert",
			["content"] = newmsg
		}
		local newdata = http:JSONEncode(data)
		http:PostAsync(url, newdata)
	end)
end)

here is what it puts: https://gyazo.com/617bdeac073576dfb6824878dd1948c5

(it still runs on "plr.Chatted" because I havent implemented it into the game yet, don't mind that)

2 comments

0

Put a space after where it says ["Username"]

0

do " "

1 answer

✓ Accepted answer

Here's an article

"Note that concatenation does not insert a space between the two strings. If you want to join two strings with a space between them, include a space at the end of the first string (or the beginning of the second string) as illustrated on line 1 above."article

Add a space before the concatenation or behind the concatenation for example.

local str = "Your high score is "
local highScore = 5200
 
local combinedString = str .. highScore
 
print(str)
print(combinedString)

OUTPUT:

Your high score is

Your high score is 5200

2 comments

0

Still not working, i'll edit my code so you can see what i did.

0

oh wait, i misread, sorry

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