So i have made a door script where i have made so if u don’t hold the key the hold duration is 0 and when u hold the key then its 1 but for some reason the hold duration circle won’t show up when u are holding the key even tho the duration is set to 1.
the circle is the circle that is around the prompt button when holding it down
help is appreciated.
here is my code if needed
hitbox.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) and hit.Parent.Humanoid.Health ~= 0 then
if hit.Parent:FindFirstChild("Room1 Key") then
prompt.HoldDuration = 1
elseif not hit.Parent:FindFirstChild("Room1 Key") then
prompt.HoldDuration = 0
end
end
end)
I dont see anything wrong in the sciprt so im just gonna tell you to check if the keys name is correct. “Room1 key”.
Also u need to hit some part to activate that function, so make sure u did that.
btw i just removed the hitbox script when i showcased what i wanted it to look like
but what i want to achieve is that i can change the hold duration and then the circle hold thing will pop up
example. when the hold duration is nil then its just instant with no circle and when its 1 in hold duration then the circle pops up
Ok so i tried it myself and i realized there rly was an issue not updating the prompt.
To fix this i would recomment making 2 prompts. 1 Without key and other with a key, and disable/enable them when holding a key. This worked perfectly for me.
local Hitbox = script.Parent.HitBox
local Lock = script.Parent.Lock
local NoKeyPrompt = Lock.NoKey
local KeyPrompt = Lock.Key
Hitbox.Touched:Connect(function(Hit)
if game.Players:GetPlayerFromCharacter(Hit.Parent) and Hit.Parent.Humanoid.Health > 0 then
local Key = Hit.Parent:FindFirstChild("Room1 Key")
if Key then
KeyPrompt.Enabled = true
NoKeyPrompt.Enabled = false
else
KeyPrompt.Enabled = false
NoKeyPrompt.Enabled = true
end
end
end)