How detect if a plugin having the needed permission?

Hello devform member! I’m creating a plugin which needs permission to add a “script”. Only, during the first installation the plugin breaks because it does not have the permission to do this which forces the user to restart his studio. So I would like to know if there is a way to know if the plugin has permission or not

2 Likes

Maybe this will help you:

Nah :confused: it’s cant help me but if the Feature was implemented its will patch my problem. But its will probably not be implemented so i need another solution

Does the user need to restart studio even if they click “allow” the first time?

Yes, this is the problem. After the user allowed the plugin he need to restart the studio

1 Like

Maybe try using “pcalls”? Else I’m not sure if anything else can help.

I’m thinking about it, but what do I do if the error is not from lack of permission?

1 Like

If it’s not from lack of permission then there is something wrong with your script? I’m not sure if I 100% understand.

In fact if I am using pcall, is there a way to check if the error is due to lack of permission?

If your plugin works correctly and you make sure no errors are in the console there shouldn’t be errors in the first place unless it’s from lack of permission so you’ll probably be fine.

Yea but, I want to check if the error is = lack of permission, well if these possible

Yeah I don’t think there is any way to check if it’s from lack of permission so your best go is to use pcall.

2 Likes

The problem still here, i try pcall but its not working, it like if the plugin code stop running because of lack of permission (with a pcall too)

I had this problem not too long ago and found this solution:

local success, failure = pcall(function()
	local test = Instance.new("Script")
	test.Name = ""
	test.Parent = game.CoreGui
	
	coroutine.resume(coroutine.create(function()
		wait(1)
		
		if test then
			test:Destroy()
		end
	end))
	
	test.Source = [[
This script is used to check if script injection is enabled.
	]]
end)

if not success then
	print("Script injection is not allowed.")
else
    print("Script injection is allowed.")
end
9 Likes