So basically I made it so when you click a GUI button it clones a key (which is in ReplicatedStorage) and puts it in the players backpack but it doesn't open the door. It works when the key is in Starterpack but when its cloned nothing happens.
Here is my code for the button to clone the key:
local p = game.Players.LocalPlayer
local Ready = true
script.Parent.MouseButton1Click:Connect(function()
if Ready == true then
local tool = game.ReplicatedStorage.Room1:Clone()
tool.Parent = p.Backpack
Ready = false
end
end)
Here is my code for the door to detect the humanoid inside the key:
function ontouch(hit)
local Doorkey = hit:findFirstChild("Doorkey1") -- Finding the Humanoid in Card Tool
if Doorkey then -- if Key Touched Then >>
script.Parent.Transparency = 0.4
script.Parent.CanCollide = false
script.Parent.Sign.BrickColor = BrickColor.Green()
wait(5)-- time for door
script.Parent.Transparency = 0
script.Parent.CanCollide = true
script.Parent.Sign.BrickColor = BrickColor.White()
end
end
script.Parent.Touched:Connect(ontouch)
Please help, Thanks!

3 comments
Thank you so much that worked perfectly!
Also how do you check if you have a certain item in your backpack (so I can replace the Ready variable)
You can use this to check if game.Players.LocalPlayer:FindFirstChild("ToolName") then