Still have questions? Join our Discord server and get real time help.
Log in to vote

Why cant i compare the different texts?

Asked by 10 days ago

im trying to make a set speed box and compare the text inside it with another text that holds my speed but it doesnt work why? local script:

if not script.Parent.Text > script.Parent.Parent.jump.Text then

game.Players.LocalPlayer.Character.Humanoid.JumpPower = script.Parent.Text


error: 17:18:54.828 - Players.world_kiIIer.PlayerGui.ScreenGui.speed.speed:1: attempt to compare string with boolean

17:18:54.828 - Stack Begin

17:18:54.829 - Script 'Players.world_kiIIer.PlayerGui.ScreenGui.speed.speed', Line 1

17:18:54.829 - Stack End idk what that means

1 answer

Log in to vote
Answered by
Vik954 43
10 days ago
Edited 10 days ago

I think that in this text box you want to enter an Number, but the Text property holds a String. To transform the String into a Number you need the tonumber() function. This way, you can compare these two.

You can also ensure your safety in the code by instead of writing not script.Parent.Text > script.Parent.Parent.jump.Text, you would write not (script.Parent.Text > script.Parent.Parent.jump.Text), so it looks at the result, not at one of the numbers.

i tried with tonumber and the brackets but it still dont work, now i got the error " p, li { white-space: pre-wrap; } attempt to compare nil with boolean" Gameplayer365247v2 166 — 10d

Answer this question