Script error 'end' expected (to close 'if' at line 7) near '<eof>'

I’m making a group rank only access to click certain things and it keeps popping up this error and i’ve tried to fix the errors but i just don’t know what to do here’s the error

[Workspace.LightSwitch.OnOff:21: ‘end’ expected (to close ‘if’ at line 7) near ‘’

Here’s my script that i’m having issues with.

local GetRankInGroup = 2929968
local rank = 255
local state = false

function onMouseClick(player) 	
	if not player then return end
	if player:GetRankInGroup(group) >= rank then
ClickDetector.mouseClick:connect(function(touched)
	state = not state
	if state then
		script.Parent.Light.PointLight.Enabled = true
		script.Parent.On.Transparency = 0
		script.Parent.Off.Transparency = 1
	else
		script.Parent.Light.PointLight.Enabled = false
		script.Parent.On.Transparency = 1
		script.Parent.Off.Transparency = 0
	end
	
	
end)	

any thing i can do to fix it?

If you indented it correctly then it would be easier for you to see that the second if statement is never closed. The function onMouseClick(player) line is also never closed.

Besides that, the rest of the code also doesn’t make sense. It looks like you’re connecting to ClickDetector.MouseClick (but spelled wrong) if the player has a rank in a group, but the actual listener ignores who the player is. Maybe you mean to just make the connection and check the player’s credentials from inside the listener?

7 Likes

You didn’t close this if statement.

3 Likes