I want to make when the user with a key, (the key collide with the door, it generates a function)
Door Script:
local Hinge = script.Parent.PrimaryPart local opened = false local key = true key1 = game.Workspace.key1.key1.Handle local opensound = script.Parent.door_open local closesound = script.Parent.door_close local lockedsound = script.Parent.door_locked local unlocksound = script.Parent.door_unlock local Promt = script.Parent:WaitForChild("ProximityPrompt") local model = script.Parent model.onModelTouched:connect(function(key1) key1 = game.Workspace.key1.key1.Handle print("Opened") key = false unlocksound:Play() end) function OpenDoor() if opened == false and key == false then opensound:Play() Promt.ActionText = "Close Door" opened = true for i = 1, 21 do script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(5), 0)) wait() end elseif opened == true then closesound:Play() Promt.ActionText = "Open Door" opened = false for i = 1, 21 do script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-5), 0)) wait() end elseif opened == false and key == true then lockedsound:Play() print("Está cerrado.") end end Promt.Triggered:Connect(function(Players) OpenDoor() end)