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

Player Requirement Check Not Working?

Hello! I was wondering why this script will not work. It should check that the player has the correct requirements in order to proceed onto the next stage. Would I have to wait for the child, find the first child, create an in pairs loop of will it be something else?

ReqAge = 20
GroupID = 000000

script.Parent.Parent.BEGIN.MouseButton1Click:connect(function(player)
	if player ~= nil then
		if player.AccountAge < ReqAge then
		player:Kick("You Must Be Atleast 20 Days Old To Apply!")
		if player:IsInGroup(GroupID) == nil then
			player:Kick("You Have Join The Group!")
			if player:IsInGroup(GroupID) and player:GetRankInGroup(GroupID) == 2 then
				player:Kick("You Have Been Suspended")
				
			else 
				script.Parent.Parent.Parent.STAGE1.Visible = false
			end
		end
	end
	end
end)

Thanks.

4 comments

0

place a 'end' to close line 8 at line 10, this should fix

0

You can use a 'elseif' too

0

Oh, ok, I will try to have a play around to see what I get.

0

Can you be more specific about what is not working? Where does it fail ( have you debugged ? )

1 answer

✓ Accepted answer



ReqAge = 20
GroupID = 000000

script.Parent.Parent.BEGIN.MouseButton1Click:connect(function(player)
  if player ~= nil then
     local rank = player:GetRankInGroup(GroupID)
     if player.AccountAge < ReqAge then
       player:Kick("You Must Be Atleast 20 Days Old To Apply!")
     --elseif player:IsInGroup(GroupID) == nil then 
     elseif rank == 0 then
       player:Kick("You Have to Join The Group!")
    --elseif player:IsInGroup(GroupID) and player:GetRankInGroup(GroupID) == 2 then
    elseif rank == 2 then
       player:Kick("You Have Been Suspended")
    else 
         script.Parent.Parent.Parent.STAGE1.Visible = false
    end
  end
end)

note that the rank will be 0 if not a member, so IsInGroup() is not strictly needed. (I commented out some lines and replaced them to demonstrate). Also note that using a rank to suspend people may not be a good idea as they can just leave the group and rejoin.

1 comment

0

Try to always keep your indentation (whitespace at start of line) neatly to prevent errors like the one in your script! Opening an if-statement (or else/elseif, function, for loop, etc) code-block moves to the right, closing it moves indentation to the left.

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