I added the line of code to the message
Pretty much:
local new = tostring(steps.Text - 1)
steps.Text = new
Im dumb LOl
Still gives same error, didn’t help anything.
you can’t set variables with if then end conditions.
Adding conditions to variables is slightly different.
they don’t use if statements at the beginning and if you want or statements you need to contain them in
parenthesis, because or is used to assign different variables to it if the first returns nil.
you can use booleans to assign numbers to variables with an and statement.
steps.Text = (Found or "nil") and "inf" or tostring(data[stagetrans.Text])
Yeah I don’t think thats gonna work…
edit: nevermind the quotation marks were weird
If i get the chance, ill get on my computer to help, i think i have a solution but i need to test it. Rn i gtg.
try removing the tostrings from the code
Attempt to perform arithmetic (sub) on string and number
tostring(tonumber(steps.Text) - 1))
attempt to perform arithmetic (sub) on nil and number
can you show me the text of Steps.Text?
When I am in the safezone its “NIL”
and out of safe zone, what does it say
Nil still because it breaks the entire script due to roblox stopping the script whenever theres an error
try this:
while task.wait(.1) do
if Humanoid.MoveDirection ~= Vector3.new(0, 0, 0) then
if steps.Text == 'NIL' then return end
local new = tostring(tonumber(steps.Text) - 1)
player.PlayerGui.StepsGUI.Frame.TextLabel.Text = text
if new <= 15 then
steps.TextColor3 = Color3.new(0.866667, 0, 0.0156863)
steps.Parent.ImageLabel.ImageColor3 = Color3.new(0.866667, 0, 0.0156863)
elseif new >= 16 then
steps.TextColor3 = Color3.new(255,255,255)
steps.Parent.ImageLabel.ImageColor3 = Color3.new(255,255,255)
end
if new <= 0 then
Humanoid.Health -=100
steps.Text = tostring(data[stagetrans.Text])
break
end
end
end
Unkown global text below local new = blah blah blah
i copied from the first post so i dont know what you changed from that one
below steps.text == “NIL” then return end
I found the issue. it couldn’t convert the string to a number so if you replace this line.
local new = tonumber(steps.Text)-1 -- Error on this line
with
local new: number = (tonumber(steps.Text) or 1) - 1
and this
steps.Text = if Found or "nil" then "inf" else tostring(data[stagetrans.Text])
with this
steps.Text = (Found or "nil") and "inf" or tostring(data[stagetrans.Text])
from your original script.