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

How can i make it so a group member will only be able to click it?

Asked by 6 years ago

This is my script so far (im VERY new to scripting)

function onClicked() script.Parent.Parent.Gate.Transparency = 1 script.Parent.Parent.Gate.CanCollide = false wait(.001) end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

I am completly lost on how to make it so let say my group and rank 123 can click this button for it to function

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Use the Player:IsInGroup() function like so:

local groupId = 123 -- change to your group id
local gate = script.Parent.Parent.Gate

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
    if plr:IsInGroup(groupId) then
        gate.Transparency = 1
        gate.CanCollide = false
    end
end)

If you want only specific ranks to be able to click it, use Player:GetRankInGroup() and do something like this:

local groupId = 123 -- change to your group id
local minRank = 100
local gate = script.Parent.Parent.Gate

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
    if plr:GetRankInGroup(groupId) >= minRank then --if its equal or greater than
        gate.Transparency = 1
        gate.CanCollide = false
    end
end)
Ad

Answer this question