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

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

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

✓ Accepted answer

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)

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