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

Can Someone Help Me With My Keycard System?

Asked by 10 years ago

In my place, I'm using keycards to open doors. However, it's not working as I want it. I'll add notes in the script to tell you as I go along.

Group = 1015675
Key = script.Parent.Keycard

function ForgeKey(LevelToPrint, Player)
    NewKey = Key:Clone()
    NewKey.Parent = game.Players:FindFirstChild(Player.Name).Backpack
    Folder = script.Parent.CardProperties:FindFirstChild("Level "..LevelToPrint)
    NewKey.Handle.BrickColor = Folder.Colour.Value
    NewKey.Handle.Reflectance = Folder.Reflectance.Value
    NewKey.Level = LevelToPrint
end

game.Players.PlayerAdded:connect(function (plyr)
    plyr.CharacterAdded:connect(function (char)
        if plyr:IsInGroup(Group) then
            Rank = plyr:GetRankInGroup(Group)
            if Rank < 50 then
                ForgeKey(1, plyr)
            elseif Rank == 52 then
                ForgeKey(3, plyr)
            elseif Rank < 200 then
                ForgeKey(2, plyr)
            elseif Rank == 202 then
                ForgeKey(4, plyr)
            elseif Rank < 253 then
                ForgeKey(4, plyr)
            elseif Rank > 252 then
                ForgeKey(5, plyr)
            end
        end
    end)
end)

Anyone see where I faltered? Thanks in advance.

1
On line 7, you should be using `BrickColor` instead of "Color". 2eggnog 981 — 10y
0
I don't see anything wrong with the code, what exactly isn't working properly? BlackJPI 2658 — 10y
0
It's simply not giving it to the player when they join. (I AM testing this online, by the way) Something may have faltered beforehand but I don't know. SquirreIOnToast 309 — 10y
0
I put in some corrections. It's still not working though. SquirreIOnToast 309 — 10y
View all comments (4 more)
1
Line 6 can be just "Player.Backpack" no need to search for it. GoldenPhysics 474 — 10y
0
Okay. Anything else? SquirreIOnToast 309 — 10y
1
Part of your problem may be having spaces in the name of the Levels in the CardProperties. Try removing the spaces, and editing your script accordingly. SlickPwner 534 — 10y
0
Seems to make no difference. SquirreIOnToast 309 — 10y

Answer this question