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

Group GUI TextButton not working?

local groupid = -- I put the ID here, taken out for the purpose of this question

script.Parent.MouseButton1Click:connect(function(clicked)
	local plr = game.Players:GetPlayerFromCharacter()
	if plr:IsInGroup(groupid) then
	if plr:GetRoleInGroup(groupid) >= 2 then
		script.Parent.Parent.Parent.Parent.Visible = false wait(.1)
		script.Parent.Parent.Parent.Parent.Parent.MainMenu.Visible = true
	else
		print("Player is not in group or does not have signifficant permissions")
				
			end
		end
end)

This is a script that when a player clicks the button, it will see if they have the right permissions (Role 2 or more) and if they do it will move onto the next screen, but it doesn't work.

It outputs this every time; Argument 1 missing or nil

Any help would be much appreciated..

2 answers

✓ Accepted answer

First of all, you've not got any arguments in the GetPlayerFromCharacter function, which is why the output says "Argument 1 missing or nil". The argument should be the character's model.

Secondly, the GetRoleInGroup YieldFunction returns a string, not a number. I think the one you're looking for is GetRankInGroup, which returns the rank number of the player in the group.

So, to solve the player problem, you need to find the player. Assuming the script in the GUI is a LocalScript, you can just do this instead of using the GetPlayerFromCharacter function:

local plr = game.Players.LocalPlayer

If you need to know what rank number a role is in a group, check the group admin page in the group and click on the Roles section. From there, modify your script so GetRoleInGroup is changed to GetRankInGroup.

2 comments

0

Thanks for your answer, However, this seems to only work in studio and not in the actual game? x3

0

You must be using a LocalScript as you are using the LocalPlayer as the plr variable.

local groupid = 1337 -- ;)

local serverside
if game.Players.LocalPlayer then
serverside = false
else
serverside = true
end

script.Parent.MouseButton1Click:connect(function(clicked)
	local plr
	if serverside then
		plr = script.Parent.Parent.Parent.Parent --wherever the player is within their playergui
	else
		plr = game.Players.LocalPlayer
	end
    if plr:IsInGroup(groupid) then
    if plr:GetRoleInGroup(groupid) >= 2 then
        script.Parent.Parent.Parent.Parent.Visible = false wait(.1)
        script.Parent.Parent.Parent.Parent.Parent.MainMenu.Visible = true
    else
        print("Player is not in group or does not have signifficant permissions")

            end
        end
end)

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