Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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

0
Ok, Thank You! Real_BoomyBoomYT 10 — 4y
Ad

Answer this question