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

Error while using if MSG ==?

Asked by 3 years ago

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

0
Show the error 0Papa_Rat0 63 — 3y
0
And the while loop is not necessary 0Papa_Rat0 63 — 3y
0
Why would you put a function connected to an event, in a while tru loop that never stops? Spjureeedd 385 — 3y
0
Why dont you indent your work, it makes thing a whole lot easier munkuush 22 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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)
0
I will try it out! Naderssrr 15 — 3y
0
Hey hey, it worked! Thanks! Naderssrr 15 — 3y
Ad

Answer this question