Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Group GUI TextButton not working?

Asked by
PredNova 130
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
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

Log in to vote
1
Answered by 9 years ago

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.

0
Thanks for your answer, However, this seems to only work in studio and not in the actual game? x3 PredNova 130 — 9y
0
You must be using a LocalScript as you are using the LocalPlayer as the plr variable. Spongocardo 1991 — 9y
Ad
Log in to vote
1
Answered by 9 years ago
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)

Answer this question