How can I create a group lock but the script isnt in the click detector

Yeah, I’m bad at LUA. The script is in a parent, and the clickdetector is in a part.
How can I group lock the click detector?

Well for your title, you could simply place/parent the Script anywhere really, just make sure that you reference your ClickDetector property though

For group locking, I’d presume that you mean when someone activates the Click Detector, then it’ll be completely disabled for anyone else to trigger?

No, just for ranks ex: 254+ can click it.

script.Parent.MouseClick:Connect(function(plr)
    if plr:GetRankInGroup(GROUPID) >= 254 then
        -- Do magic
    end
end

Gotcha, well provided you know how the .Triggered Event works for ClickDetectors, we can obtain the Player through that automated parameter easily, and we can use a function that’s called Player:GetRankInGroup(), and this can return back (I believe) 2 possibilities

  • The Current Rank the Player is in
  • nil (Or like if the Player isn’t in the group and such)

Since you only want players to only toggle it if they’re Rank 254+, we can create a couple of variables that we’ll use later on within our .Triggered Event, and check if they’re the exact Rank (Or higher) to run that code on:

local GroupID = 00000 -- Placeholder, replace it with your code
local RankRequirement = 254
local ClickDetector = ClickDetectorObjectHere -- Another placeholder

Next, we’d wanna create a function to connect our Event to (Like connecting a wire from Point A, to Point B)

local function Clicked(Player) -- This is passed as our first argument
    local PlrRank = Player:GetRankInGroup(GroupID)

    if PlrRank >= RankRequirement then
        print(Player, "is a high enough rank to activate this!")
        -- Do your special code stuff here
    else
        print(Player, "is not a high enough rank.")
    end
end

Print statements can be handy for debugging purposes, so make sure to toggle your Output Tab whenever you can :wink:

Last, we just have to connect our Event…

ClickDetector.MouseClick:Connect(Clicked)

And our code should look like this in its full entirety!

local GroupID = 00000 -- Placeholder, replace it with your code
local RankRequirement = 254
local ClickDetector = ClickDetectorObjectHere -- Another placeholder

local function Clicked(Player) -- This is passed as our first argument
    local PlrRank = Player:GetRankInGroup(GroupID)

    if PlrRank >= RankRequirement then
        print(Player, "is a high enough rank to activate this!")
        -- Do your special code stuff here
    else
        print(Player, "is not a high enough rank.")
    end
end

ClickDetector.MouseClick:Connect(Clicked)

Of course, please make sure to go through the documentations and research if you haven’t done so already & if you have any questions feel free to ask :slightly_smiling_face:

Thanks, I’ll try this later today, and MAS if it worked! <3

Aaa,


See what I mean, I get this error underline thang.

Not only that but


my doors unweld when I use the code sample on the documents

This is because ClickDetectorObjectHere is literally as the name suggests, you replace that with your own ClickDetector object and parent it where it’s supposed to be

I’ve only used that as a reference to give an example on what the variable is about

I don’t know how your Explorer hierarchy works, so you’ll have to figure it out by referencing it slowly parent by parent

local ClickDetector = workspace.Somewhere.OfficeSingleWindow.Handle:WaitForChild("ClickDetector")

The handle and stuff still fall apart.
image

That is something you’d have to create a separate topic on, as I don’t know much about Welding and such

All I’ll say is that, you could probably weld it together by using some Motor6D's or WeldConstraints unless if they’re manually welded together

1 Like

Thanks for ur help!
lots of characrrersara

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.