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.

8 comments

1

On line 7, you should be using BrickColor instead of "Color".

0

I don't see anything wrong with the code, what exactly isn't working properly?

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.

0

I put in some corrections. It's still not working though.

1

Line 6 can be just "Player.Backpack" no need to search for it.

0

Okay. Anything else?

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.

0

Seems to make no difference.