Hi, I have this script that is suppose to show when you touch the block, it is passed through a remote event. The script stops working when it reaches if Popss:Get(amountNeeded) >= amountNeeded then, any help is appreciated.
local RemoteEventFolder = game.ReplicatedStorage.unLock
local RemoteEvent = RemoteEventFolder.unlockPort
RemoteEvent.OnServerEvent:Connect(function(Player)
local DataStore2 = require(script.DS2)
local B_ = require(script.Parent.Parent.priceToUnlock)
local amountNeeded = B_.Port
local Popss = DataStore2("Pops", Player)
if Popss:Get(amountNeeded) >= amountNeeded then
local PlayerGui = Player:WaitForChild("PlayerGui")
local unlockGui = script.Unlockable:Clone()
unlockGui.Parent = PlayerGui
end
end)
1 Like
that probably means that the amountNeeded from Popss is not bigger or equal to the amountNeeded from B_.Port. Try printing these values, and maybe try adding an “else” to the IF, so you’ll know if the condition is met or not. I’m not an expert (rather average/below average scripter), but that’s what I would try
I added and else statement, made it say print(“i”). It printed “i”, but I don’t know why it’s doing that. My value is currently 169 so it is higher.
are you changing the value on client?
can you also verify what the exact value of B_.Port is?
can also try printing them on event like so:
print("I have " … Popss:Get(amountNeeded) … " Required: " … amountNeeded)
use the above line and then we can move on after u tell us whats being printed @SimplyRangel
150 is the value of B_.Port, I changed it to <= instead of >= and the gui popped up but it is confusing, are you able to explain if you can?
Before
if Popss:Get(amountNeeded) >= amountNeeded then
After
if Popss:Get(amountNeeded) <= amountNeeded then
Either you are not changing the values on server or you are not properly saving or fetching the values
use this print after declaring popps:
print("I have " … Popss:Get(amountNeeded) … " Required: " … amountNeeded)