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 a part only interactive with Group members?

I have successfully made a shirt that can be clicked on with a click detector and disappear(fade away).

I have been trying to make it so the click detector(disable/enable) only works when a certain ranked group member** (rank 2 and up) clicks on it.

I have failed numerous times and I am actually kinda embarrassed to put my failed script on here .-.

/ here is my little fade away script

-- Variables

local detector = script.Parent
local cooldown = false
local part = detector.Parent

-- Particles

local Glow = part.Attachment.Glow
local Sparkles = part.Sparkles

part.BrickColor = BrickColor.Random()

Glow.Color = ColorSequence.new(part.Color,part.Color)
Sparkles.Color = ColorSequence.new(part.Color,part.Color)

detector.MouseClick:Connect(function()
	if cooldown == false then
		cooldown = true
		Sparkles.Enabled = false
		Glow:Emit(1)
		Sparkles:Emit(5)
		for i = 1,20 do
			part.Transparency = part.Transparency + 0.05
			wait(0.01)
		end
		part.CanCollide = false
		detector.MaxActivationDistance = 0
		wait(math.random(30,600))
		
		part.BrickColor = BrickColor.Random()
		Glow.Color = ColorSequence.new(part.Color,part.Color)
        Sparkles.Color = ColorSequence.new(part.Color,part.Color)
		
		for i = 1,20 do
			part.Transparency = part.Transparency - 0.05
			wait(0.01)
		end
		part.CanCollide = true
		Sparkles.Enabled = true
		detector.MaxActivationDistance = 10
		cooldown = false
	end
end)

1 answer

✓ Accepted answer

Being that MouseClick has a single parameter of playerWhoClicked, we can run a single if statement with the :GetRankInGroup() method.

-- Variables

local detector = script.Parent
local cooldown = false
local part = detector.Parent
local GroupId = 00
local AdminRank = 00

-- Particles

local Glow = part.Attachment.Glow
local Sparkles = part.Sparkles

part.BrickColor = BrickColor.Random()

Glow.Color = ColorSequence.new(part.Color,part.Color)
Sparkles.Color = ColorSequence.new(part.Color,part.Color)

detector.MouseClick:Connect(function(player)
    if cooldown == false and player:GetRankInGroup(GroupId) >= AdminRank then
        cooldown = true
        Sparkles.Enabled = false
        Glow:Emit(1)
        Sparkles:Emit(5)
        for i = 1,20 do
            part.Transparency = part.Transparency + 0.05
            wait(0.01)
        end
        part.CanCollide = false
        detector.MaxActivationDistance = 0
        wait(math.random(30,600))

        part.BrickColor = BrickColor.Random()
        Glow.Color = ColorSequence.new(part.Color,part.Color)
        Sparkles.Color = ColorSequence.new(part.Color,part.Color)

        for i = 1,20 do
            part.Transparency = part.Transparency - 0.05
            wait(0.01)
        end
        part.CanCollide = true
        Sparkles.Enabled = true
        detector.MaxActivationDistance = 10
        cooldown = false
    end
end)

2 comments

0

I actually tested your script, on my backup acc that is in the team create and for some reason the shirts with the new script was still visible, im gonna test again out of studio and in the actual place

0

It Works! thanks lots man :P

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