Problems With Converting String To Number

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Turn a TextBox.Text Into A Number
  2. What is the issue? Include screenshots / videos if possible!
    It Wont Let Me Do IT
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Ive Tried Tonumber Yet It Dosent Work
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local TextBox = script.Parent.Parent.TextBox
local Power = 0
local Spin = 0
local Step = 1
local Deb = true 
TextBox:GetPropertyChangedSignal("Text"):Connect(function()
	TextBox.Text = TextBox.Text:gsub('%D+', '');
end)
script.Parent.Activated:Connect(function()
	if Deb == true then
	if Step == 1 then
			Power = TextBox.Text
		Step = 2
		script.Parent.Parent.Text = "Spin"
			TextBox.Text = "0"
	else
		Spin = TextBox.Text
		Step = 1
		Deb = false
		script.Parent.Parent.Text = "Power"
			TextBox.Text = "0"
game.ReplicatedStorage.BowlingActive:FireServer(Power, Spin, game.Players.LocalPlayer)			
	end
	wait(5)
	Deb = true
	end
end)

This Is A Local Script Btw

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

tonumber should work, can you show us how you used it in your failed attempt?
also

why are you passing in this to the remote event?

1 Like

Its going to a server script (In the future to use for a bowling system)
Also Yeah 1 sec

I hope you know that OnServerEvent already returns the player for you, lol.

1 Like

local TextBox = script.Parent.Parent.TextBox
local Power = 0
local Spin = 0
local Step = 1
local Deb = true
TextBox:GetPropertyChangedSignal(“Text”):Connect(function()
TextBox.Text = TextBox.Text:gsub(‘%D+’, ‘’);
end)
script.Parent.Activated:Connect(function()
if Deb == true then
if Step == 1 then
Power = TextBox.Text
Step = 2
script.Parent.Parent.Text = “Spin”
TextBox.Text = “0”
else
Spin = TextBox.Text
Step = 1
Deb = false
script.Parent.Parent.Text = “Power”
TextBox.Text = “0”
game.ReplicatedStorage.BowlingActive:FireServer(tonumber(Power), tonumber(Spin), game.Players.LocalPlayer)
end
wait(5)
Deb = true
end
end)

wait ok ty i might know whats wrong

Let me guess, the error was something like “attempt to perform arithmetic on Player”

1 Like

it was 18:43:00.844 ServerScriptService.BowlingMain:2: attempt to concatenate Instance with string - Server - BowlingMain:2

how would i get the player with the event?

It’s the very first parameter. So in your case:
.OnServerEvent:Connect(player, power, spin)

1 Like

i have that and it gives me this error with this print 18:46:07.538 ServerScriptService.BowlingMain:4: attempt to concatenate Instance with string - Server - BowlingMain:4
and the print is print(Player…“Player”) i just figured out that its because i need player.name Tysm

2 Likes

yeah thats what I was trying to hint at with my little note at the end, I should’ve cleared it up lol. Thanks for helping him out while i was gone!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.