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

Expected end (to close function at line 16) got elseif?

what did i do i added an end but it still underlines elseif

local plrs = game.Players
local sss = game.ServerScriptService
local groupId = 7870490
local chatService = require(sss:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))
local PassService = game:GetService("MarketplaceService")

chatService.SpeakerAdded:Connect(function(plr)
	
	local speaker = chatService:GetSpeaker(plr)
		
	if plrs[plr]:IsInGroup(groupId) then
		
		speaker:SetExtraData('NameColor', Color3.fromRGB(0, 255, 178))
		speaker:SetExtraData('Tags', {{TagText = plrs[plr]:GetRoleInGroup(groupId), TagColor = Color3.fromRGB(255, 37, 37)}})
		
game.Players.PlayerAdded:Connect(function(plrss)		
	elseif PassService:UserOwnsGamePassAsync(plrss.UserId,11925441) then
		speaker:SetExtraData('NameColor', Color3.fromRGB(186, 106, 106))
		speaker:SetExtraData('Tags', {{TagText = "VIP", TagColor = Color3.fromRGB(246, 255, 65))
		   end
		end)
	end)
end)

3 comments

0

Thats because you are continuing the if statement inside of another function.

0

wdym

0

on line 11, you are starting an if statement. and you never ended it until after you made a function on line 16. you then said elseif on line 17, continuing the if statement you made on line 11.

1 answer

This. Won't. Work. You know why? You put elseif inside another function. That's not how if elseif else statements work. They have to be in the same function, not in different functions. Examples:

if then
	function()
		elseif then
or
		else
	end)
end

This won't work ^, since you put elseif or else inside another function. But this will work.

if then
	function()
	end)
elseif then

or

else

end

This ^ will work, since they're both in the same function/thread thing.

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