Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

ServerScriptService.UpgradeEvent:14: attempt to compare string with number?

I need help with this. how do i convert a string to a number?

here is how i get the String

local value = script.Parent.Parent.TextBox.Text

This is a another script ^^^^

And here is the script

wait(3)

local event = game.ReplicatedStorage.Events.UpgradeEvent

print("A")
event.OnServerEvent:Connect(function(player,stat,valuea)
	
	print("A")
	
	print(player, stat)
	
	local stats = player.Stats
	
14	if stats.UpgradePoints.Value >= valuea then
	
	stats.stat.Value = stats.stat.Value + valuea
	stats.stat.Value = stats.stat.Value - valuea
	
	end
end)

1 answer

✓ Accepted answer

Tonumber is the answer to your question

local value = tonumber(script.Parent.Parent.TextBox.Text)

Tonumber will return nil if it finds a non-numeric character in the string

1 comment

0

Ok, Thank You!

This discussion is preserved as it was. New answers, comments, and votes are closed.