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

end expected to close function?

Asked by 5 years ago
Edited 5 years ago

i maded a question like 8 hours ago and it seems to have worked.. BUT however it is STILL broken!

the full script:

--//Admin Commands Script
--//Variables\\--
local DataStore = game:GetService("DataStoreService")
local BanList = DataStore:GetDataStore("BanList")
local Admins = {"no, i wont give u free admin"} --//admins

--//Events\\--
game.Players.PlayerAdded:connect(function(Player)
    local Folder = Instance.new("Folder", Player)
    Folder.Name = "PlayerValues"

    local BanCheck = Instance.new("BoolValue", Folder)
    BanCheck.Name = "IsBanned"
    BanCheck.Value = BanList:GetAsync(Player.userId) or false --//False is default if no save for the player

--//Checks if the player is banned or not
if Player.PlayerValues.IsBanned.Value == true then
    Player:Kick("You're Banned From This Game.") --//Reason for kick
end

Player.Chatted:connect(function(message)
    for i, AdminName in ipairs(Admins) do
        if Player.Name == AdminName then
            --//Commands\\--
            --//Kill Command
            if message:sub(1, 6) == "/kill " then
                local TargetPlayer = game.Players:FindFirstChild(message:sub(7))
                if TargetPlayer then
                    local Character = TargetPlayer.Character
                    if Character then
                        Character.Humanoid.Health = 0
                    end
                end
            end

                --//Heal Command
                if message:sub(1, 6) == "/heal " then
                    local TargetPlayer = game.Players:FindFirstChild(message:sub(7))
                    if TargetPlayer then
                        local Character = TargetPlayer.Character
                        if Character then
                            Character.Humanoid.Health = Character.Humanoid.MaxHealth
                        end
                    end
                end

                --//Kick Command
                if message:sub(1, 6) == "/kick " then
                    local TargetPlayer = game.Players:FindFirstChild(message:sub(7))
                    if TargetPlayer then
                        TargetPlayer:Kick("Kicked by " .. Player.Name) --//Kick message/reason
                    end
                end

                --//Ban Command
                if message:sub(1, 5) == "/ban " then
                    local TargetPlayer = game.Players:FindFirstChild(message:sub(6))
                    if TargetPlayer then
                        local BanCheck = TargetPlayer.PlayerValues.IsBanned
                        if BanCheck then
                            BanCheck.Value = true
                            BanList:SetAsync(TargetPlayer.userId, true)
                        end
                        TargetPlayer:Kick("You've been banned from this game by " .. Player.Name) --//Reason || Message
                    end
                end

                --//Unban Command
                if message:sub(1, 7) == "/unban " then --//USES ID NOT NAME
                    local UserId = tonumber(message:sub(8))
                    if UserId then
                        BanList:SetAsync(UserId, false)
                    end
                end
            --//im cencoring this command xdd

                        end)
                break
            end
        end
    end
        end
    end)

the problem is at line 8, when i place end it breaks other parts.

0
Please paste the code in your question rather than in a pastebin. User#19524 175 — 5y
0
sure RedLecko434 -1 — 5y
0
there RedLecko434 -1 — 5y
0
connect & the 2nd argument of Instance.new is deprecate green271 635 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

The solution is pretty simple, and you're probably going to be kicking yourself in the face in a minute, but that's part of programming. Anyway, your error starts at line 8, and ends at the end of your function

game.Players.PlayerAdded:connect(function(Player)
    local Folder = Instance.new("Folder", Player)
            Folder.Name = "PlayerValues"

    local BanCheck = Instance.new("BoolValue", Folder)
            BanCheck.Name = "IsBanned"
            BanCheck.Value = BanList:GetAsync(Player.userId) or false --//False is default if no save for the player

--//Checks if the player is banned or not
    if Player.PlayerValues.IsBanned.Value == true then
            Player:Kick("You're Banned From This Game.") --//Reason for kick
    end

You have two 'blocks' here (i'm sure that's not the proper terminology but i'm sticking with it) , your function, and the if statement. At the moment, your if statement is the only 'block' that has been closed. So, to tell the program where the function stops, you need to add an end, but with a )

game.Players.PlayerAdded:connect(function(Player)
    local Folder = Instance.new("Folder", Player)
            Folder.Name = "PlayerValues"

    local BanCheck = Instance.new("BoolValue", Folder)
            BanCheck.Name = "IsBanned"
            BanCheck.Value = BanList:GetAsync(Player.userId) or false 


    if Player.PlayerValues.IsBanned.Value == true then
            Player:Kick("You're Banned From This Game.")
    end
end) --Sneaky, eh?

Always double check your code, an error is usually caused by something pretty simple. ;3

0
this script is frustratuing -.- got again the error on line 21 RedLecko434 -1 — 5y
0
you probably just forgot to put a ) on the end of the function turtle2004 167 — 5y
Ad
Log in to vote
0
Answered by
Time_URSS 146
5 years ago
Edited 5 years ago

The easy thing to do is to add another end at the end, as you forgot to add one.

Hope it works!

0
Dosent Work RedLecko434 -1 — 5y

Answer this question