While I was writing my code it seemed to be fine, ran smoothly without any errors but when I added another elseif block into my code it suddenly decided to underline itself in red and print the error message: "Expected 'end' (to close 'function' at line 37), got 'elseif'". I am not sure as why of why this is happening, if I could get any help, this would be heavily appreciated. Thank you in advance! ![]()
Here’s my code:
local ManualBanned = {"NACKRR"}
local Admins = {"NACKRR"}
local Prefix = ";"
local dss = game:GetService("DataStoreService")
local bds = dss:GetDataStore("BanDataStore")
function checkAdmin(name)
for i, v in pairs(Admins) do
if v == name then return true else return false end
end
end
function setOutput(plr, text)
plr.PlayerGui.AdminPanel.CommandBackground.Output.Text = tostring(text)
wait(5)
plr.PlayerGui.AdminPanel.CommandBackground.Output.Text = ""
end
game.Players.PlayerAdded:Connect(function(player)
local userid = player.UserId
local banned
if ManualBanned[userid] then
player:Kick("You have been banned by a Developer")
end
local success, errormessage = pcall(function()
local playeruserid = player.UserId
banned = bds:GetAsync(playeruserid)
end)
if banned then
player:Kick("You have been banned by an Administrator")
end
end)
function execCommand(cmd, plr)
local args = cmd:split(" ")
--// Kill Function \\--
if args[1] == Prefix.."kill" then
if game.Players:FindFirstChild(args[2]) then
game.Players:FindFirstChild(args[2]).Character.Humanoid.Health = 0
else
setOutput(plr, "Player Not Found, "..tostring(args[2]))
end
elseif args[1] == Prefix.."speed" then
if game.Players:FindFirstChild(args[2]) then
if args[3] then
game.Players:FindFirstChild(args[2]).Character.Humanoid.WalkSpeed = tonumber(args[3])
else
setOutput(plr, "Invalid Argument, "..tostring(args[3]))
end
else
setOutput(plr, "Player Not Found, "..tostring(args[2]))
end
elseif args[1] == Prefix.."jump" then
if game.Players:FindFirstChild(args[2]) then
if args[3] then
game.Players:FindFirstChild(args[2]).Character.Humanoid.JumpPower = tonumber(args[3])
else
setOutput(plr, "Invalid Argument, "..tostring(args[3]))
end
else
setOutput(plr, "Player Not Found, "..tostring(args[2]))
end
elseif args[1] == Prefix.."bring" then
if game.Players:FindFirstChild(args[2]) then
game.Players:FindFirstChild(args[2]).Character.HumanoidRootPart.CFrame = plr.Character.HumanoidRootPart.CFrame + Vector3.new(0, 2, 0)
else
setOutput(plr, "Player Not Found, "..tostring(args[2]))
end
elseif args[1] == Prefix.."goto" then
if game.Players:FindFirstChild(args[2]) then
plr.Character.HumanoidRootPart.CFrame = game.Players:FindFirstChild(args[2]).Character.HumanoidRootPart.CFrame + Vector3.new(0, 2, 0)
else
setOutput(plr, "Player Not Found, "..tostring(args[2]))
end
elseif args[1] == Prefix.."jail" then
if game.Players:FindFirstChild(args[2]) then
game.Players:FindFirstChild(args[2]).Character.HumanoidRootPart.CFrame = game.Workspace.JailTeleport.CFrame
else
setOutput(plr, "Player Not Found, "..tostring(args[2]))
end
elseif args[1] == Prefix.."unjail" then
if game.Players:FindFirstChild(args[2]) then
game.Players:FindFirstChild(args[2]).Character.HumanoidRootPart.CFrame = game.Workspace.UnjailTeleport.CFrame
else
setOutput(plr, "Player Not Found, "..tostring(args[2]))
end
elseif args[1] == Prefix.."kick" then
if game.Players:FindFirstChild(args[2]) then
game.Players:FindFirstChild(args[2]):Kick("An Administrator has kicked you from the game")
else
setOutput(plr, "Player Not Found, "..tostring(args[2]))
end
elseif args[1] == Prefix.."ban" then
if game.Players:FindFirstChild(args[2]) then
local playerforban = game.Players:FindFirstChild(args[2])
local userid = playerforban.UserId
local success,errormessage = pcall(function()
bds:SetAsync(userid, true)
end)
if success then
print("User has been banned")
end
playerforban:Kick("You are banned")
else
setOutput(plr, "Player Not Found, "..tostring(args[2]))
end
elseif args[1] == Prefix.."unban" then
local playerforban = game.Players:FindFirstChild(args[2])
local userid = args[2]
local success,errormessage = pcall(function()
bds:SetAsync(userid, false)
end)
if success then
print("User has been unbanned")
end
else
setOutput(plr, "Player Not Found, "..tostring(args[2]))
end
elseif args[1] == Prefix.."give" then
print("Ran")
end
end
game.ReplicatedStorage.Remotes.ExecuteCommand.OnServerEvent:Connect(function(plr, cmd)
if checkAdmin(plr.Name) then
execCommand(cmd, plr)
else
setOutput(plr, "Invalid Permission Level")
end
end)