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

How can I make a part only interactive with Group members?

Asked by
Burobuu 18
6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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)
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 Burobuu 18 — 6y
0
It Works! thanks lots man :P Burobuu 18 — 6y
Ad

Answer this question