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

This script is not working for me?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Hello. I added lines to the script, so instead of letting players pass doors who are from my group, instread it lets door be passed by specific ranks on my group, so i changed the script a bit, but now the doors are not working at all!

CurrentGroup = 2684229 -- Change this to GroupID of your group
Door = script.Parent -- Do not modify
IsActive = false -- Do not modify
KillOnContact = false -- If true, kills non group members, if false does not let them in.
WaitTime = 2 -- Amount of time door remains open
G1 = script.Parent.Parent.Green1
G2 = script.Parent.Parent.Green2
R1 = script.Parent.Parent.Red1
R2 = script.Parent.Parent.Red2


function Touched(Part)
    if IsActive then return end
    IsActive = true
    if Part.Parent then
        Player = game.Players:playerFromCharacter(Part.Parent)
        if Player then
            if Player:IsInGroup(CurrentGroup) then
            if Player:GetRankInGroup(CurrentGroup) == 255
            if Player:GetRankInGroup(CurrentGroup) == 254
            if Player:GetRankInGroup(CurrentGroup) == 80
            end
        end
                Open()
            else
                print("Atleast it exists?")
                R1.BrickColor = BrickColor.new("Really red")
                R2.BrickColor = BrickColor.new("Really red")
                if KillOnContact then Part.Parent:breakJoints()
                wait(WaitTime)
                R1.BrickColor = BrickColor.new("Black")
                R2.BrickColor = BrickColor.new("Black")
                end
            end
        end
    end
    IsActive = false
end

function Open()

    G1.BrickColor = BrickColor.new("Lime green")
    G2.BrickColor = BrickColor.new("Lime green")
    Door.Transparency = 1
    Door.CanCollide = false
    wait(WaitTime)
    G1.BrickColor = BrickColor.new("Black")
    G2.BrickColor = BrickColor.new("Black")
    Door.CanCollide = true
    Door.Transparency = 0

end

Door.Touched:connect(Touched)
0
Read the output. Lines 18-21 aren't even finished. 1waffle1 2908 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

GetRankInGroup can and sometimes is sketchy to be used. I consider using GetRoleInGroup instead. It is basically the same except instead of returning the RankId of the player, it returns the role name.

So lets say for instance ( this is just an example script ), you have a group with the ID of 2525294. In that group with said ID you have a rank called "MLG"

Here is how it would check if the player is in that group ( place script in a wall part )

script.Parent.Touched:connect(function(hit)
    if game.Players:FindFirstChild(hit.Parent.Name) then
        local player = game.Players:FindFirstChild(hit.Parent.Name)
        print("is a player")
        if player:IsInGroup(2525294) then
            print("player is in group")
            if player:GetRoleInGroup(2525294) == "MLG" then
                print("player is in group and the role of him/her is MLG")
                script.Parent.CanCollide = false
                wait(2)
                script.Parent.CanCollide = true
            end
        end
    end
end)

Hope this helped!

0
Just an fyi, lines 18-21 are not complete, you wrote 3 different if's without then's in a single if statement. You can combine this all like: disassembling 48 — 8y
0
if player:IsInGroup(CurrentGroup) and player:GetRankInGroup(CurrentGroup) == 255 or 254 or 80 then disassembling 48 — 8y
0
@disassembling thanks for telling this method. I didnt know that you can use after the == multiple values. Also, could the multiple values after == work with GetRoleInGroup too or no? CraftioLo 0 — 8y
Ad

Answer this question