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

Error while using if MSG ==?

Hello, I was making a script that if you say “Nad is my best friend”, then it will make a sign saying “Me and nad are best friends!”. When I tried the script, it pulled up an error. Here is the script I’m into today:

while true do
game.Players.Naderssrr.Chatted:Connect(function(msg)
if msg == "Nad is my best friend" then
local model2 = Instance.new("Part")
model2.Parent = game.workspace
model2.Size = Vector3.new(36,32.2,2)
model.Anchored = true
surface2 = Instance.new("SurfaceGui")
		surface2.Parent = model2
		textla2 = Instance.new("TextLabel")
		textla2.Parent = surface2
		textla2.Size = UDim2.new(1,0,1,0)
		textla2.Position = UDim2.new(0,0,0,0)
		textla2.Visible = true
		textla2.Text = "Me and nad are best friends!"
		textla2.TextScaled = true
end)
wait()
end

Please help me you wonderful and brilliant scripters. Regarding, Naderssrr

4 comments

0

Show the error

0

And the while loop is not necessary

0

Why would you put a function connected to an event, in a while tru loop that never stops?

0

Why dont you indent your work, it makes thing a whole lot easier

1 answer

✓ Accepted answer

here is your fixed code

	local player = game.Players:WaitForChild("Naderssrr") 
	player.Chatted:Connect(function(msg)
		if msg == "Nad is my best friend" then
			local model2 = Instance.new("Part")
			model2.Parent = game.Workspace
			model2.Size = Vector3.new(36,32.2,2)
			model2.Anchored = true
			local surface2 = Instance.new("SurfaceGui")
			surface2.Parent = model2
			local textla2 = Instance.new("TextLabel")
			textla2.Parent = surface2
			textla2.Size = UDim2.new(1,0,1,0)
			textla2.Position = UDim2.new(0,0,0,0)
			textla2.Visible = true
			textla2.Text = "Me and nad are best friends!"
			textla2.TextScaled = true
		end
		end)

2 comments

0

I will try it out!

0

Hey hey, it worked! Thanks!

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