I made a custom proximity prompt for a door model, but I’m getting “MouseButton1Click is not a valid member of TextLabel” as the error in the output. What’s causing this? Am I doing it correctly?
To explain the sequence there are basically custom proximity prompts, one that opens/closes the door and one that locks it.
StarterGUI
Door Model
LocalScript of GUI:
local PromptGui = script.Parent
local OpenButton = PromptGui:WaitForChild("OpenButton")
local OpenText = PromptGui:WaitForChild("OpenText")
local LockButton = PromptGui:WaitForChild("LockButton")
local LockText = PromptGui:WaitForChild("LockText")
local door = workspace.FrontDoor
local openPrompt = door.Arch.Attachment:WaitForChild("OpenProximityPrompt")
local lockPrompt = door.Arch.Attachment:WaitForChild("LockProximityPrompt")
local Remote = game.ReplicatedStorage:WaitForChild("DoorStateChangeEvent")
local function updateGuiText(isOpen, isLocked)
if isLocked then
LockText.Text = "Unlock"
else
LockText.Text = "Lock"
end
if isOpen then
OpenText.Text = "Close"
else
OpenText.Text = "Open"
end
end
Remote.OnClientEvent:Connect(function(isOpen, isLocked)
updateGuiText(isOpen, isLocked)
end)
OpenButton.MouseButton1Click:Connect(function()
openPrompt:InputHoldBegin()
end)
LockButton.MouseButton1Click:Connect(function()
lockPrompt:InputHoldBegin()
end)
updateGuiText(false, false)
Script inside the door model:
local PromptGui = script.Parent
local OpenButton = PromptGui:WaitForChild("OpenButton")
local OpenText = PromptGui:WaitForChild("OpenText")
local LockButton = PromptGui:WaitForChild("LockButton")
local LockText = PromptGui:WaitForChild("LockText")
local door = workspace.OrphanageFrontDoor
local openPrompt = door.Arch.Attachment:WaitForChild("OpenProximityPrompt")
local lockPrompt = door.Arch.Attachment:WaitForChild("LockProximityPrompt")
local Remote = game.ReplicatedStorage:WaitForChild("DoorStateChangeEvent")
local function updateGuiText(isOpen, isLocked)
if isLocked then
LockText.Text = "Unlock"
else
LockText.Text = "Lock"
end
if isOpen then
OpenText.Text = "Close"
else
OpenText.Text = "Open"
end
end
Remote.OnClientEvent:Connect(function(isOpen, isLocked)
updateGuiText(isOpen, isLocked)
end)
OpenButton.MouseButton1Click:Connect(function()
openPrompt:InputHoldBegin()
end)
LockButton.MouseButton1Click:Connect(function()
lockPrompt:InputHoldBegin()
end)
updateGuiText(false, false)
Any help is very much appreciated, thanks!