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

Why is my team change button script not working?

Asked by 8 years ago

Hello scripters! I have a little problem. So i have 4 buttons for each team. Each button has 2 scripts inside them, who are ran on same time. First script kills player once button is pressed, and it works fine, but the second script is supposed to check is the player in certain rank in my group and then switch he's team if he is. The second script is not working. Ill post below the 2 scripts, maybe they are not compatible with each other.

Kill script:

function onButtonClicked()
script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0
end

script.Parent.MouseButton1Click:connect(onButtonClicked)

Team change script:

function Click(mouse)
    if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(268422)
        print ("IS IN A GROUP!")
         if player:GetRoleInGroup(268422) == "Marked" then

script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Bright green")
end


script.Parent.MouseButton1Down:connect(Click)

1 answer

Log in to vote
0
Answered by 8 years ago

You do not need two separate scripts, so here is a single block of code that is the solution to your question.

function Click(mouse)
    script.Parent.Parent.Parent.Parent.Parent.Character.Health=0
    if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(268422)
        print("IS IN A GROUP!")
        if player:GetRankInGroup(268422) ~= 0 then -- Look for Reason (A) below this code,
            script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Bright green")
        end -- You forgot the end(s) for the if(s)
    end
end
script.Parent.MouseButton1Down:connect(Click)

Reason (A): If you were to use GetRoleInGroup, it would look for the group's rank name (For Example, Recruit [LR] ; General [HR]), but with GetRankInGroup, the Rank is the number from editing the group's roles, such as the guest's rank 0. With "GetRankInGroup(##) ~= 0", it would not allow any rank 0, which is a person not associated with the group, to activate the team switch

0
Great now the button doesn't work at all. I dont understand. Here are so many pro scripters and good scripters, but nobody is able to help me get one script working? CraftioLo 0 — 8y
0
I just started scripting this summer, or was it last? I have such a bad memory that I shouldn't try helping, MaplebloxX54321 15 — 8y
Ad

Answer this question