Hello! Does anyone know why my keyModel is not being destroyed in my code? what’s wrong?
-- Get references to frame and key ProximityPrompts
local frameModel = script.Parent.Parent.Frame
local keyModel = script.Parent.Parent.Key
local keyProximityPrompt = keyModel.keyModelBase:WaitForChild("keyProximityPrompt")
-- Get reference to the frame ProximityPrompt trigger
local frameTriggered = frameModel.basePart:WaitForChild("frameProximityPrompt")
-- Connect the function to the frame ProximityPrompt activation
frameTriggered.Triggered:Connect(function()
print("Frame ProximityPrompt Triggered")
-- Wait for a short time before destroying the frame
wait(0.2)
frameModel:Destroy()
-- Wait for an additional time before enabling the key ProximityPrompt
task.wait(0.5)
keyProximityPrompt.Enabled = true
end)
task.wait(.2)
-- Connect the function to the key ProximityPrompt activation
keyProximityPrompt.Triggered:Connect(function()
print("Key ProximityPrompt Activated")
-- Wait for a short time before destroying the key model
wait(0.5)
keyModel:Destroy()
end)