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

Button only pressable by a specific team not working?

Asked by 3 years ago

I am working on an SCP game, and I am making an admin event that is only pressable by admins. The script I have will not work, here is the script:

function onClick(click)
local group = script.Parent.Parent.Parent
if click.TeamColor == BrickColor.new("Lime green") then


    local GasPart = game.Workspace.LCZdecon
    local doubleparent = script.Parent.Parent
    --Sounds
    doubleparent.min1:Play()
    wait(30)
    doubleparent.sec30:Play()
    wait(38)
    doubleparent.Begun:Play()
    --Gas and killpart
    GasPart.Part1.Smoke.Enabled = true
    GasPart.Part2.Smoke.Enabled = true
    GasPart.Part3.Smoke.Enabled = true
    GasPart.Part4.Smoke.Enabled = true
    GasPart.Part5.Smoke.Enabled = true
    GasPart.Part6.Smoke.Enabled = true
    GasPart.Part7.Smoke.Enabled = true
    GasPart.Part8.Smoke.Enabled = true
    GasPart.Part9.Smoke.Enabled = true
    GasPart.Part10.Smoke.Enabled = true
    GasPart.Part11.Smoke.Enabled = true
    GasPart.Part12.Smoke.Enabled = true
    GasPart.Part13.Smoke.Enabled = true
    GasPart.Part14.Smoke.Enabled = true
    GasPart.KillPart.Script.Disabled = false
    GasPart.KillPart.CanTouch = true

    print("Decontamination Engaged by admin")
else
    print("Unauthorized player attempted to activate decontamination.")
end

end

script.Parent.MouseClick:Connect(onClick)

If anyone can help I would appreciate it.

2 answers

Log in to vote
0
Answered by 3 years ago

script.Parent.ClickDetector.MouseClick:Connect(function(plr)

            if plr.TeamColor == BrickColor.new("Lime green")   then
 print("TEAM COLOR IS REALLY BLACK")


local GasPart = game.Workspace.LCZdecon
local doubleparent = script.Parent.Parent
--Sounds
doubleparent.min1:Play()
wait(30)
doubleparent.sec30:Play()
wait(38)
doubleparent.Begun:Play()
--Gas and killpart
GasPart.Part1.Smoke.Enabled = true
GasPart.Part2.Smoke.Enabled = true
GasPart.Part3.Smoke.Enabled = true
GasPart.Part4.Smoke.Enabled = true
GasPart.Part5.Smoke.Enabled = true
GasPart.Part6.Smoke.Enabled = true
GasPart.Part7.Smoke.Enabled = true
GasPart.Part8.Smoke.Enabled = true
GasPart.Part9.Smoke.Enabled = true
GasPart.Part10.Smoke.Enabled = true
GasPart.Part11.Smoke.Enabled = true
GasPart.Part12.Smoke.Enabled = true
GasPart.Part13.Smoke.Enabled = true
GasPart.Part14.Smoke.Enabled = true
GasPart.KillPart.Script.Disabled = false
GasPart.KillPart.CanTouch = true

end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
Ad
Log in to vote
-1
Answered by 3 years ago
Edited 3 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

this is the code that worked for me

script.Parent.ClickDetector.MouseClick:Connect(function(plr)

    if plr.TeamColor == BrickColor.new("Really black")   then
        print("TEAM COLOR IS REALLY BLACK")
    end


end)

edit:

also to make it easier you can change:

GasPart.Part1.Smoke.Enabled = true
    GasPart.Part2.Smoke.Enabled = true
    GasPart.Part3.Smoke.Enabled = true
    GasPart.Part4.Smoke.Enabled = true
    GasPart.Part5.Smoke.Enabled = true
    GasPart.Part6.Smoke.Enabled = true
    GasPart.Part7.Smoke.Enabled = true
    GasPart.Part8.Smoke.Enabled = true
    GasPart.Part9.Smoke.Enabled = true
    GasPart.Part10.Smoke.Enabled = true
    GasPart.Part11.Smoke.Enabled = true
    GasPart.Part12.Smoke.Enabled = true
    GasPart.Part13.Smoke.Enabled = true
    GasPart.Part14.Smoke.Enabled = true

to this instead:

for i = 1,14 do
GasPart["Part"..i].Smoke.Enabled = true

end

This makes you write less code since the difference between each line is the number after "Part" which is quite predictable as it is a pattern(starts at 1 and goes up by 1 each time till 14)

Answer this question