I wanted to make that it’s checking after triggering “ProximityPrompt” how many candies he has and if he has under 150 it’s doing something, if he has exactly 150 it’s doing something and if he has more than 150 then it’s going to do something.
It means, I was trying:
if Candies == 150 then
-- script here about exactly
end
elseif Candies > 150 then -- i tried to make if he has more than 150.
-- script here when you have more than 150 (that's example).
end
-- But I can't find how to detect lower than 150 and it can't detect Value.
The issue is that it can’t detect Value.
Yes, I tried to find good helpful ones, but it still don’t work for me.
PromptVariable.Triggered:Connect(function(playerwhoTriggered)
if playerwhoTriggered.Candies == 150 then
-- script here about exactly
end
elseif playerwhoTriggered.Candies > 150 then -- i tried to make if he has more than 150.
-- script here when you have more than 150 (that's example).
end
end)
Make sure the script is server sided, also it wont work with the client script since it tells you the player who triggered it. I hope this helps
Some flaws inside your code
first off, assuming “Candies” is a ValueBase that is storing your data, you should do Candies.Value to detect the value or change it
second, use debounces so the client cannot spam the proximity prompt and listen to it in the server
thirdly, there’s an extra “end” here:
if Candies == 150 then
end --Remove this
elseif Candies > 150 then -- i tried to make if he has more than 150.
end
Sorry for the mistake I’ve made @Doxelix , turns out it CAN work in a client script, but if your script is originally in the workspace then it may not be working. Try parenting it to the ServerStorage and clone the script to each player that joins. Then I believe it may work. Also as UMirin said, there is an extra end in your code.
local ProximityPrompt = workspace.Guy.Torso.ProximityPrompt
--script here
ProximityPrompt.Enabled = false
--script
wait(4)
ProximityPrompt.Enabled = true
--the end of script
if Candies < 150 then
-- your script
elseif Candies == 150 then
-- your second script
elseif Candies >= 150 then
-- your final script
end
If you do that, it will do something if its lower than 150, if its equal to 150 and if its higher than 150. So if you want something who happens only with higher than 150, you can do it, same with less and equal.
And if you’re thinking that “huh uh there is candies >= 150 so it will also happen with 150” you are wrong because the equals 150 is before that, so if its 150 it will never encounter the “>= 150”