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)
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)