Leaderstats Door UI visible not working

I tried creating a script where if yo click this door:
image
It should display this frame:


But it does not work and gives this error:

This is the script inside the door
image
This is the script

local Player = game.Players.LocalPlayer 
local Frame = game.StarterGui.LeaderstatsDoorUI.LeaderstatsDoorFrame
local Button = game.StarterGui.LeaderstatsDoorUI.LeaderstatsDoorFrame.BuyButtonUI
local Button2 = game.StarterGui.LeaderstatsDoorUI.LeaderstatsDoorFrame.CloseButtonUI



local RequiredCoins = 2000

local debounce = true
script.Parent.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
Frame.Visible = true
	
	end)

This is the script inside the frame’s buy button:

local leaderstatsDoor = game.Workspace.Door1
local player = game.Players.LocalPlayer
local RequiredCoins = 2000
script.Parent.MouseButton1Click:Connect(function()
	if player.leaderstats.Coins.Value >= RequiredCoins then
		leaderstatsDoor.Transparency = 1
		leaderstatsDoor.CanCollide = false
	elseif player.leaderstats.Coins.Value < RequiredCoins then
		leaderstatsDoor.Transparency = 0.5
		leaderstatsDoor.CanCollide = true
	end
end)

Please do help me as I was not able to get to know what was the problem

Since you’re referring to ClickDetector it should be “MouseClick”, MouseButton1Click is only for gui buttons.

Ok thanks let me check that real quick

I tried that but this is the error:
image

not the parent of the click detector
the click detector itself

You need to specify it as a clickdetector.
Basically you can see at line 11 I added "script.Parent.ClickDetector.MouseClick:Connect(function()"

local Player = game.Players.LocalPlayer 
local Frame = game.StarterGui.LeaderstatsDoorUI.LeaderstatsDoorFrame
local Button = game.StarterGui.LeaderstatsDoorUI.LeaderstatsDoorFrame.BuyButtonUI
local Button2 = game.StarterGui.LeaderstatsDoorUI.LeaderstatsDoorFrame.CloseButtonUI



local RequiredCoins = 2000

local debounce = true
script.Parent.ClickDetector.MouseClick:Connect(function()
local player = game.Players.LocalPlayer
Frame.Visible = true
	
	end)

it did not work and no error also

You have to put a ClickDetector inside of the object that the player clicks and make sure you use ‘MouseClick’
Paste this in and try:
1st script:

local Player = game.Players.LocalPlayer 
local Frame = game.StarterGui.LeaderstatsDoorUI.LeaderstatsDoorFrame
local Button = game.StarterGui.LeaderstatsDoorUI.LeaderstatsDoorFrame.BuyButtonUI
local Button2 = game.StarterGui.LeaderstatsDoorUI.LeaderstatsDoorFrame.CloseButtonUI



local RequiredCoins = 2000

local debounce = true
script.Parent.ClickDetector.MouseClick:Connect(function()
local player = game.Players.LocalPlayer
Frame.Visible = true
	
	end)

2nd script:

local leaderstatsDoor = game.Workspace.Door1
local player = game.Players.LocalPlayer
local RequiredCoins = 2000
script.Parent.ClickDetector.MouseClick:Connect(function()
	if player.leaderstats.Coins.Value >= RequiredCoins then
		leaderstatsDoor.Transparency = 1
		leaderstatsDoor.CanCollide = false
	elseif player.leaderstats.Coins.Value < RequiredCoins then
		leaderstatsDoor.Transparency = 0.5
		leaderstatsDoor.CanCollide = true
	end
end)