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

'end' expected (to close 'function' at line 6) near '<eof>'

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID="

game.Players.PlayerAdded:connect(function(player)
player.chatted:connect(function(msg)
local msg = msg:lower()
 if msg == "/e punch" then
local animTrack = player.Character.Humanoid:LoadAnimation(animation)
animTrack:Play()
end

'end' expected (to close 'function' at line 6) near ''

3 answers

You are missing two "end)"s for your connect lines.

2 comments

0

Please explain more?

0

You didn't do an ordinary connection line. You did a Mass Connection line which most people think is much easier. If you can see in the line, It's missing ')' so at the last end, you have to add it there.

'Please explain more'

Every functions needs an end, every anonymous function needs an end and a close parenthesis, because it's left open at the beginning;

:connect**(function() end)**

This coroutine is left open twice, therefore needs to have two closed parenthesis.

coroutine.resume**(coroutine.create(function() end))**

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID="

game.Players.PlayerAdded:connect(
    function(player)
        player.chatted:connect(
            function(msg)
                local msg = msg:lower()
                if msg == "/e punch" then
                    local animTrack = player.Character.Humanoid:LoadAnimation(animation)
                    animTrack:Play()
                end
            end
        )
    end
)

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