How to convert string to number?

Hello, I’m Pixeluted I doing music that player can buy But I got a problem I need to convert string to number
But I don’t know-how
Thank for any tips
Pixeluted

It’s a simple method:

tonumber(string)

However, I think you can still do the whole ID on sounds:
rbxassetid://stringId


Warning: You cannot convert strings with other characters than numbers, it will return nil.

10 Likes

im sure you can use string like @Operatik said .

Okay thank, but in TextBox is text nothing but I writing numbers of id into TextBox But is still nil

That’s strange, try using method B:

"rbxassetid://" .. input

Input is the text added into the TextBox.

That I trying do is still nil I don’t know why Look at picture

1 Like

Wait a second, I think I know the issue here:

  • You are trying to read player input from server - you cannot see what the player has changed on the box. Try using remotes to pass the value to the server, specifically a RemoteFunction.
3 Likes

Thank it’s working Thank so much

2 Likes

Wow, it’s that easy? I thought it would be something more complex.

1 Like