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

Script not recognizing rank inside group?

So, I have a script that is meant to detect if you're the owner of the group which ID you put inside the textBox, but it keeps returning me as NOT the owner. My Username: TheHospitalDev Testing Group: http://www.roblox.com/My/Groups.aspx?gid=2732066

Script:



local create = script.Parent
local frame = script.Parent.Parent
local id = script.Parent.Parent.groupID.Text
local plr = game.Players.LocalPlayer
 
local ap = require(game.Workspace.TrelloAPI)

create.MouseButton1Click:connect(function()   
    if tonumber(id) and plr:GetRankInGroup(tonumber(id)) == 255 then --Line 12
        wait()
        local group = game:GetService("GroupService"):GetGroupInfoAsync(tonumber(id.Text))
        local BoardID = ap:GetBoardID("Appalachian Security Contract Application")
        local ListID = ap:GetListID("Applied",BoardID)
        local CardID = ap:AddCard("[NS] " .. group.Name, game.Players.LocalPlayer.Name, id, ListID)
        print("He's the owner!!!!")
        script.Parent.Parent.create.Visible = false
        wait(3)
    game.Players.LocalPlayer:Kick("Thank you for choosing Appalachian Private Security Company, we hope you choose us again! -APSC")
	
    else
		print("He's NOT the owner!!!!")
		script.Parent.Parent.Warn.Visible = true
		script.Parent.Parent.create.Visible = false
		wait(5)
		script.Parent.Parent.Warn.Visible = false
		script.Parent.Parent.create.Visible = true
    end
end)

If you need the GUI to test it, please post in comments!

1 answer

✓ Accepted answer
local id = script.Parent.Parent.groupID.Text

When you created this variable, you didn't store the TextButton, but rather you stored the current string that the TextLabel had. This means that the Text value won't update again when the player changes it. Therefore, you can fix the script by changing that to this:

local id = script.Parent.Parent.groupID

-- snip

create.MouseButton1Click:connect(function()
	local groupID = tonumber(id.Text) -- Use more variables and organize your code.
	if plr:GetRankInGroup(groupID) == 255 then
		-- snip
	end
end)

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