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

Admin commands help?

Asked by
IcyEvil 260 Moderation Voter
9 years ago

Alright there is an Error on line 15 that says I need an end but I add an End and all it does is say the exact same thing.

Replicants = {"amegaman","papertiger67"}

function Text(text,time,par,Texttype)
local m=Instance.new(Texttype)
m.Parent=par
m.Text=text
wait(time)
if m~=nil then
m:Destroy()
end
end
game.Players.PlayerAdded:connect(function(plr)
for i,v in pairs(Replicants)do
if plr.Name:lower()==v:lower()then
plr.Chatted:connect(function(msg)
if msg:lower()=="@m" or msg:lower() == "@message" then
Text("This is a message!",4,workspace,"Message")
end
elseif msg:lower():sub(1,9)=="@m/"or "@message/" then  --'end' expected to close 'function' at line 15 near elseif
Text(plr.Name..": "..msg:sub(4),4,workspace,"Message")
end
end)
end
end
end)

Any help?

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

Tab your code properly.

It makes it easier to read and completely eliminates these errors.

Here is your code:

function Text(text,time,par,Texttype)
    local m=Instance.new(Texttype)
    m.Parent=par
    m.Text=text
    wait(time)
    if m~=nil then
        m:Destroy()
    end
end

game.Players.PlayerAdded:connect(function(plr)
    for i,v in pairs(Replicants)do
        if plr.Name:lower()==v:lower()then
            plr.Chatted:connect(
                function(msg)
                    if msg:lower()=="@m" or msg:lower() == "@message" then
                        Text("This is a message!",4,workspace,"Message")
                    end -- REMOVE ME
                    elseif msg:lower():sub(1,9)=="@m/"or "@message/" then
                        Text(plr.Name..": "..msg:sub(4),4,workspace,"Message")
                    end
                end
            )
        end
    end
end)

Notice yoru elseif. It is not attached to any if because the previous one was already ended.

Remove the end immediately before it and it should work fine.

0
THANKS. IcyEvil 260 — 9y
Ad

Answer this question