edit: Grammer.

local frame = script.Parent
local clickDetector = frame:WaitForChild("ClickDetector")

local function unlock()
	script.Parent.Parent.RedLock.Anchored = false
	frame.Script.Disabled = false
	script.Disabled = true
end
clickDetector.MouseClick:Connect(function(plr)
	if plr.Backpack:FindFirstChild("Redkey") then
		plr.Backpack.Redkey:Destroy()
		unlock()
	end
end)
script.Parent.Touched:Connect(function(hit)
	if hit.Parent.Name == "Redkey" then
		unlock()
	end
end)

This is the script, I made sure everything was named correctly. I have zero clue why it isn't working. Can someone help me out here?

3 comments

0

Do you have a warning that says 'Infinite yield possible on frame:WaitForChild("ClickDetector")'

0

Tell us more, did you try using print("") to detect what was happening, what isn't working in the script, ect.

0

use a print() after the if statement in the touched event. does it print?