ProximityPrompt is not enabling

  1. What do you want to achieve?
    I want to enable a ProximityPrompt when an IntValue hits 5

  2. What is the issue?
    It just doesn´t work

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I haven´t looked for solutions on the devhub, however, I tried a lot other solutions, I tried using global variables, a detector that activates the prompt once a condition is fulfilled, etc. The “Enabled” property of the prompt never set to true in any of this

This is the code

local prompt = script.Parent
local value = workspace.MaderaFuego
prompt.Enabled = false

if value.Value == 5 then
	prompt.Enabled = true
	end
2 Likes
local prompt = script.Parent
local value = workspace.MaderaFuego
prompt.Enabled = false

function enable() 
	if value.Value == 5 and not prompt.Enabled then
		prompt.Enabled = true
	end
end

--we run it once in case the condition is met before the value changes
enable() 
--you have to listen for when the value changes!
value.Changed:Connect(enable)
3 Likes

When you click play, this code will run as soon as the game is loaded, and so if the value is not already 5, your conditional will not run no matter what since this is sequential programming. Try wrapping all of this in a Value.Changed event and see what happens.

3 Likes

You seem to only be checking once if the value is equal to 5. Try running a RenderStepped function to check every frame if the value is 5.

2 Likes
local prompt = script.Parent
local value = workspace.MaderaFuego
prompt.Enabled = false

value:GetPropertyChangedSignal("Value"):Connect(function()
     if value.Value == 5 then
	   prompt.Enabled = true
     end
end)```
2 Likes

There is no reason to constantly check for the value, .Changed does that for us.

5 Likes
local prompt = script.Parent
local value = workspace.MaderaFuego
prompt.Enabled = false

value.Changed:Connect(function(newVal)
    if newVal == 5 then
	    prompt.Enabled = true
    end
end
2 Likes

@MrPurpleNathan @Xitral @NyrionDev @krasycheckz @1Urge
Thanks for answering, however, I was unable to get this to work even after trying what you adviced me, I will leave you a like for trying to help me tho.

2 Likes

Wait, is this a local script?
ThemChars

1 Like

nope, a server script, but don´t worry, I solved it already, thanks

2 Likes

I have had this problem before. You have to change the if statement a little bit.

if value.Value >= 5 then
       prompt.Enabled = true
end