You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want this line of code to show, not just after I interact with it
What is the issue? Include screenshots / videos if possible!
I want for proximity prompt action text to be unlocked, yet it unlocks after I interact with it
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Yes I did.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local OutsideKnob = script.Parent
local Door = OutsideKnob.Parent
local OutsideProx = OutsideKnob.ProximityPrompt
local InsideProx = Door.InsideKnob.ProximityPrompt
local Sound = Instance.new("Sound")
local Locked = "Locked"
local Unlocked = "Unlocked"
OutsideProx.Triggered:Connect(function(playerWhoTriggered)
Sound.Parent = OutsideKnob
Sound.SoundId = "rbxassetid://134969396"
Sound.Playing = true
OutsideProx.ActionText = "Locked"
if InsideProx.ActionText == Unlocked then
OutsideProx.ActionText = Unlocked
end
end)
local OutsideKnob = script.Parent
local Door = OutsideKnob.Parent
local OutsideProx = OutsideKnob.ProximityPrompt
local InsideProx = Door.InsideKnob.ProximityPrompt
local Sound = Instance.new("Sound")
local Locked = "Locked"
local Unlocked = "Unlocked"
OutsideProx.Triggered:Connect(function(playerWhoTriggered)
Sound.Parent = OutsideKnob
Sound.SoundId = "rbxassetid://134969396"
Sound:Play()
OutsideProx.ActionText = if InsideProx.ActionText == Unlocked then Unlocked else Locked
end)
What do you mean by locked? I use it incase, why bother writing same thing for third time when you can just put 1 line of code and you might use it, in programming you need to automate stuff else it will be a headache, I used Sound:Play() it didn’t work now it seems to work, I can give you the inside prox script, but I need to make sure it works, but problem is it’s inside event and I can’t fire it outside.
local InsideKnob = script.Parent
local Prox = InsideKnob.ProximityPrompt
local Door = InsideKnob.Parent
local Sound = InsideKnob.Sound
local Locked = “Locked”
local Unlocked = “Unlocked”
local Interact = “Interact”
–Unlock door sound “rbxassetid://157167203”
–Locked door sound “rbxassetid://134969396”
InsideKnob.ProximityPrompt.Triggered:Connect(function(playerWhoTriggered)
if Prox.ActionText == Interact then
Prox.ActionText = Locked
Sound.SoundId = “rbxassetid://134969396”
Sound.Playing = true
elseif Prox.ActionText == Unlocked then
Sound.SoundId = “rbxassetid://157167203”
Sound.Playing = true
end
end)
Your script seems to have a few issues as I could not replicate your behaviour using yours, I remade the script but did not understand which one is which so you can change OutsideKnob and InsideKnobs places.
This script is located inside the “Door”
local OutsideKnob = script.Parent.OutsideKnob
local InsideKnob = script.Parent.InsideKnob
local InsideProx = InsideKnob.ProximityPrompt
local InsideSound = InsideKnob.Sound
local OutsideProx = OutsideKnob.ProximityPrompt
local OutsideSound = OutsideKnob.Sound
local CurrentState = Instance.new("StringValue")
CurrentState.Value = "Locked"
local Debounce = false
CurrentState.Changed:Connect(function()
if CurrentState.Value == "Unlocked" then
OutsideProx.ActionText = "Unlocked"
else
OutsideProx.ActionText = "Interact"
end
end)
OutsideProx.Triggered:Connect(function(plr)
if not Debounce then
Debounce = true
if CurrentState.Value == "Locked" then
OutsideProx.ActionText = "Locked"
task.wait(2)
OutsideProx.ActionText = "Interact"
end
Debounce = false
end
end)
InsideProx.Triggered:Connect(function(plr)
if CurrentState.Value == "Locked" then
CurrentState.Value = "Unlocked"
else
CurrentState.Value = "Locked"
end
end)