Custom Cakescript chat function problem

So, I’m trying to insert a custom function into cakescript to make it so that admins can use /ev to create event text, IE:


[EVENT]:TEXT

However, it is bricking the script. I think I f’ed up the if statement somewhere, but I’m not sure. Can someone look this over, and see where I’ve gone wrong? Thankies.


function Event ( ply, text )
		if( ply:IsAdmin( ) or !ply:IsSuperAdmin( ) ) then
					
		for k, v in pairs( player.GetAll( ) ) do
		
			CAKE.SendChat( v, " [EVENT]: " .. text );
			
		else
		
		CAKE.SendChat(ply, "You must be an administrator to create events.");
			
	end
	
	return "";

end

First of all your function Event is too generic a name to be safe as a global function, if someone else called their function or variable Event then your scripts would be incompatible.
For future reference, the [noparse][lua][/lua][/noparse] tags are better for displaying lua code than the code tags.
[lua]function Event ( ply, text )
if( ply:IsAdmin( ) or !ply:IsSuperAdmin( ) ) then
for k, v in pairs( player.GetAll( ) ) do
CAKE.SendChat( v, " [EVENT]: " … text );
else
CAKE.SendChat(ply, “You must be an administrator to create events.”);
end
return “”;
end[/lua]
This is how your code is currently parsed, this is a problem because you are missing an end from the for loop. Your code should look like this:
[lua]function Event ( ply, text )
if( ply:IsAdmin( ) or !ply:IsSuperAdmin( ) ) then
for k, v in pairs( player.GetAll( ) ) do
CAKE.SendChat( v, " [EVENT]: " … text );
end
else
CAKE.SendChat(ply, “You must be an administrator to create events.”);
end
return “”;
end[/lua]