I am in the process of making a cabin assignment system for a cruise ship. I am attempting to have keys that have a unique identity to the player cloned into ReplicatedStorage. Unfortunately, it's not working. Whenever I attempt to clone the key from the backpack to RS, the console prints a "CabinKey is not a valid member of Backpack" error. Not sure why, because CabinKey is in Backpack. Please note, all the code functions properly except for the last line. The tool clones just fine into my backpack.
game.Players.PlayerAdded:connect(function(Player) Player.Chatted:connect(function(msg) if Player:GetRankInGroup(2874319) >= 240 or Player.Name == "LoonyLeftist" then if string.sub(msg,1,9) == "giveCabin" then local plr = "Nil" local players = {} local length = string.len(string.sub(msg,15,string.len(msg))) for i,v in pairs(game.Players:GetChildren()) do table.insert(players,v.Name) end for i,v in pairs(players) do if string.sub(msg,15,string.len(msg)) == string.sub(players[i],0,length) then plr = players[i] end end for i,v in pairs(game.Players:GetChildren()) do if string.lower(v.Name) == string.lower(plr) then player = v end end if plr ~= "Nil" then game.ServerStorage.CabinKey:Clone().Parent = player.Backpack player.Backpack.CabinKey.Handle.Value.Value = string.sub(msg,11,13) player.Backpack.CabinKey.Handle.Player.Value = plr player.Backpack.CabinKey.Name = string.sub(msg,11,13) player.Backpack.CabinKey:Clone().Parent = game.ReplicatedStorage else local sound = Instance.new("Sound") sound.SoundId = "rbxassetid://595978693" sound.Parent = Player.PlayerGui sound:Play() end end end end) end) --giveCabin B02 Dj --1234567890123456
Any help would be greatly appreciated!