Trying to ranklock a admin panel

I am making an admin panel so ofc I am trying to lock it to a certain rank in a group, but no matter what I try it doesn’t work.

I have tried:
Print Debugging
Messing with the script
Reversing the if statement
(I don’t really want to just disable the GUI because exploiters can get it easier.)

game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(groupid) >= minRank then
		
	else
		script.Parent:Destroy()
	end
end)

image

1 Like

Just tried enabling and disabling, it doesn’t work.

It looks okay, though you may want to change the script(s) to a LocalScript. In this case, the script would get destroyed instantly if an exploiter joins, meaning they shouldn’t be able to access the scripts.

what? exploiters can access localscripts. they cant access server scripts so they are more secure.

Yeah, but what I’m trying to tell you is that if you’re destroying the parent (which will destroy the descendants of it), it will destroy the scripts too, meaning the exploiters cant access them.

Remember, exploiters can only access THEIR client.

1 Like

You could contain the rank-locked UI in ServerStorage and after checking, cloning the UI into the player’s PlayerGui depending on whether they are a certain rank or not

1 Like

Didn’t work. Very odd. I also didn’t get any errors. :confused:

Where are you containing the script, and what does the script consist?

Alright, here’s what you need to do:

Turn ServerScripts to LocalScripts. Remember, as I stated, if the UI is getting destroyed as the player is joining, they can’t read or access the script, nor UI. Keep this in mind: Using ServerScripts in StarterGui can be server heavy, since they aren’t meant for that, but can run there.

Also, I’d believe you are in the group, invalidating what the script is doing. Try to test it on an alt and get back to me.

I did it on the alt and changing the type of script won’t help.

Yeah but a player’s gui should only ever be handled by local scripts.

Under the GUI, and what do you mean what does it consist??
image

I never use localscripts. Why should I?

https://developer.roblox.com/en-us/api-reference/class/LocalScript

The script handling the addition of the UI shouldn’t be in the UI itself neither should any server scripts be in it

Gosh guys, y’all arent giving this guy the right solution.

The answer is wayy too simple, the PlayerAdded doesnt fire properly in studio as the event fires before your scripts properly load in. Its better to test it ingame because the scripts are already loaded in.

Trust me, i went through the same experience…

If you want to test it in studio maybe delay the script. or even better DONT use PlayerAdded at all. Let it run like this

if plr:GetRankInGroup(groupid) >= minRank then
		
	else
		script.Parent:Destroy()
	end

No PlayerAdded event, because the scripts activates immediately after loading in.

I did that. Lol. Didn’t work. Not exactly “easy” now is it. :confused:

The problem is that that is not ALL the code I have in there.

local config = require(game:GetService("ServerScriptService"):WaitForChild("Read Me // Configuration"))
local groupid = config.GroupID
local minRank = config.minRank
local banDataStore = game:GetService("DataStoreService"):GetDataStore(config.banDataStore)
local introSpecIsAwesome = config.introspecIsAwesome
local debounce = false
local open = false


if introSpecIsAwesome then
	print("Introspec is awesome!")
else
	print("Wow you don't think Introspec is awesome.. :(")
end

game.Players.PlayerAdded:Connect(function(plr)
	if plr:GetRankInGroup(groupid) >= minRank then
		script.Parent:Clone().Parent = plr:WaitForChild("PlayerGUI")
	else
		print("Nope!")
	end
end)

script.Parent.ImageButton.MouseButton1Click:Connect(function()
	if debounce == false then
		if open == false then
			debounce = true
			script.Parent.MainScreen.Visible = true
			wait(.0001)
			script.Parent.MainScreen:TweenSize(UDim2.new(0.519, 0,0.685, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce)
			wait(1)
			for _,v in pairs(script.Parent.MainScreen:GetChildren()) do
				if v.ClassName ~= "UICorner" then
					v.Visible = true
				end
			end
			open = true
			debounce = false
		elseif open == true then
			debounce = true
			for _,v in pairs(script.Parent.MainScreen:GetChildren()) do
				if v.ClassName ~= "UICorner" then
					v.Visible = false
				end
			end
			wait(.0001)
			script.Parent.MainScreen:TweenSize(UDim2.new(0,0,0,0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce)
			wait(1)
			script.Parent.MainScreen.Visible = false
			open = false
			debounce = false
		end
	end
end)

function openWarn()
	-- Close Ban GUI
	for _,v in pairs(script.Parent.ReasonPromptBan:GetChildren()) do
		if v.ClassName ~= "UICorner" then
			local Info = TweenInfo.new(1)
			local Tween = game:GetService("TweenService"):Create(v,Info,{TextTransparency=1})
			Tween:Play()
			wait()
			v.Visible = true
		end
	end
	script.Parent.ReasonPromptBan:TweenSize(UDim2.new(0.202, 0,0.685, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce)
	script.Parent.ReasonPromptBan.Visible = false
	-- Close Kick GUI
	for _,v in pairs(script.Parent.ReasonPromptKick:GetChildren()) do
		if v.ClassName ~= "UICorner" then
			local Info = TweenInfo.new(1)
			local Tween = game:GetService("TweenService"):Create(v,Info,{TextTransparency=1})
			Tween:Play()
			wait()
			v.Visible = true
		end
	end
	script.Parent.ReasonPromptKick:TweenSize(UDim2.new(0.202, 0,0.685, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce)
	script.Parent.ReasonPromptKick.Visible = false
	-- Open Warn GUI
	script.Parent.ReasonPromptWarn.Visible = true
	script.Parent.ReasonPromptWarn:TweenSize(UDim2.new(0.202, 0,0.685, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce)
	for _,v in pairs(script.Parent.ReasonPromptWarn:GetChildren()) do
		if v.ClassName ~= "UICorner" then
			v.Visible = true
			local Info = TweenInfo.new(1)
			local Tween = game:GetService("TweenService"):Create(v,Info,{TextTransparency=0})
			Tween:Play()
		end
	end
end

function openKick()
	-- Close Warn GUI
	for _,v in pairs(script.Parent.ReasonPromptWarn:GetChildren()) do
		if v.ClassName ~= "UICorner" then
			local Info = TweenInfo.new(1)
			local Tween = game:GetService("TweenService"):Create(v,Info,{TextTransparency=1})
			Tween:Play()
			v.Visible = true
		end
	end
	script.Parent.ReasonPromptWarn:TweenSize(UDim2.new(0.202, 0,0.685, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce)
	script.Parent.ReasonPromptWarn.Visible = false
	-- Close Ban GUI
	for _,v in pairs(script.Parent.ReasonPromptBan:GetChildren()) do
		if v.ClassName ~= "UICorner" then
			local Info = TweenInfo.new(1)
			local Tween = game:GetService("TweenService"):Create(v,Info,{TextTransparency=1})
			Tween:Play()
			wait()
			v.Visible = true
		end
	end
	script.Parent.ReasonPromptBan:TweenSize(UDim2.new(0.202, 0,0.685, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce)
	script.Parent.ReasonPromptBan.Visible = false
	-- Open Kick GUI
	script.Parent.ReasonPromptKick.Visible = true
	script.Parent.ReasonPromptKick:TweenSize(UDim2.new(0.202, 0,0.685, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce)
	for _,v in pairs(script.Parent.ReasonPromptKick:GetChildren()) do
		if v.ClassName ~= "UICorner" then
			v.Visible = true
			local Info = TweenInfo.new(1)
			local Tween = game:GetService("TweenService"):Create(v,Info,{TextTransparency=0})
			Tween:Play()
		end
	end
end

function openBan()
	-- Close Warn GUI
	for _,v in pairs(script.Parent.ReasonPromptWarn:GetChildren()) do
		if v.ClassName ~= "UICorner" then
			local Info = TweenInfo.new(1)
			local Tween = game:GetService("TweenService"):Create(v,Info,{TextTransparency=1})
			Tween:Play()
			wait(1)
			v.Visible = true
		end
	end
	script.Parent.ReasonPromptWarn:TweenSize(UDim2.new(0.202, 0,0.685, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce)
	script.Parent.ReasonPromptWarn.Visible = false
	-- Close Kick GUI
	for _,v in pairs(script.Parent.ReasonPromptKick:GetChildren()) do
		if v.ClassName ~= "UICorner" then
			local Info = TweenInfo.new(1)
			local Tween = game:GetService("TweenService"):Create(v,Info,{TextTransparency=1})
			Tween:Play()
			wait()
			v.Visible = true
		end
	end
	script.Parent.ReasonPromptKick:TweenSize(UDim2.new(0.202, 0,0.685, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce)
	script.Parent.ReasonPromptKick.Visible = false
	-- Open ban GUI
	script.Parent.ReasonPromptBan.Visible = true
	script.Parent.ReasonPromptBan:TweenSize(UDim2.new(0.202, 0,0.685, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Bounce)
	for _,v in pairs(script.Parent.ReasonPromptBan:GetChildren()) do
		if v.ClassName ~= "UICorner" then
			v.Visible = true
			local Info = TweenInfo.new(1)
			local Tween = game:GetService("TweenService"):Create(v,Info,{TextTransparency=0})
			Tween:Play()
		end
	end
end

script.Parent.MainScreen.Warn.MouseButton1Click:Connect(function()
	if debounce then
		print("Debouncing!")
	else
		debounce = true
		openWarn()
		wait(2)
		debounce = false
	end
end)

script.Parent.MainScreen.Kick.MouseButton1Click:Connect(function()
	if debounce then
		print("Debouncing!")
	else
		debounce = true
		openKick()
		wait(2)
		debounce = false
	end
end)

script.Parent.MainScreen.Ban.MouseButton1Click:Connect(function()
	if debounce then
		print("Debouncing!")
	else
		debounce = true
		openBan()
		wait(2)
		debounce = false
	end
end)

I don’t want to change it incase anything here breaks when I do .

huh so your saying that your Destroy() doesnt work? now thats weird indeed.

We’re actually giving him really good reasons as to why it isn’t working. The PlayerAdded event works perfectly fine in Roblox Studio. The problem lies in the GetRankInGroup function itself.