local NumMaxstr = script.Parent
local NumMinstr = script.Parent.Parent.MinCLI
local plrData = game.Players.LocalPlayer.leaderstats.CannonLevel.Value
local min = 1
local max = 10
local check = function()
wait(0.2)
--Max Check
local NumMax = tonumber(NumMaxstr.Text)
if NumMax == nil then
NumMaxstr.Text = max
elseif NumMax ~= nil then
if NumMax > max then
NumMaxstr.Text = max
elseif NumMax < min then
NumMaxstr.Text = min
end
end
--Min Check
local NumMin = tonumber(NumMinstr.Text)
if NumMin == nil then
NumMinstr.Text = min
elseif NumMin ~= nil then
if NumMin > max then
NumMinstr.Text = max
elseif NumMin < min then
NumMinstr.Text = min
end
end
local NumMax = tonumber(NumMaxstr.Text)
local NumMin = tonumber(NumMinstr.Text)--Refresh Var
--Plr Data Check
print(NumMax)
print(NumMin)
print(plrData)
if not NumMin <= plrData and not plrData <= NumMax then
if NumMax <= plrData then
NumMaxstr = plrData
elseif NumMin > plrData then
NumMaxstr = plrData
end
end
end
NumMaxstr:GetPropertyChangedSignal("Text"):Connect(check)
NumMinstr:GetPropertyChangedSignal("Text"):Connect(check)
This is a join up queue I’m attempting, it allows the customizability that the “Player level” is in side the min and max values then check if its own plr value is inside its custom min and max.
For some reasons(I don’t know can someone explain please), you shouldn’t do local plrData = game.Players.LocalPlayer.leaderstats.CannonLevel.Value. Instead do: local plrData = game.Players.LocalPlayer.leaderstats.CannonLevel
and add .Value to the plrData when comparing.
Thanks Its working better, Unrelated Question, Can you tell when a TextBox is being edited, because anychange the player gives is corrected by the script before they can change anything making it uneditable.
@sjr04
That was my current solution, I connected the function at the bottom. The problem with that is, if you do a check and see if the text box is empty and have it filled in, its impossible to edit as its an infinite loop fixing its self soon as its empty.
For future reference: because of operator precedence, you can wrap your conditions in parenthesis to enforce evaluation order. Switching the operation order isn’t necessary, this can be patched with just parenthesis. I find it cleaner not to do this though.
if (not (NumMin <= plrData)) and (not (plrData <= NumMax)) then
The outer parenthesis is not necessary and you can just opt to put them around the comparison only. This example puts parenthesis around entire conditions as well as comparisons.