What do you want to achieve?
I want to enable a ProximityPrompt when an IntValue hits 5
What is the issue?
It just doesn´t work
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
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)
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.
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)```
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
@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.