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

TextBox.Text tonumber not working?

When i load into game it sets walkspeed to 0 no matter what, how do i fix the issue?

function click ()
	
	local spt = script.Parent.Text
	
	if spt ~= nil then
		script.Parent.TextV.Value = tonumber(spt)
	end
	
	local f = script.Parent.TextV.Value
	print("WalkSpeed Set to: " .. script.Parent.TextV.Value)
	script.Parent.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = f -- goes to LocalPlayers Walkspeed Value
	
end

script.Parent.Button.MouseButton1Click:Connect(click)

enter image description here

2 comments

0

What is the text you are trying to convert to a number?

0

What ever is in the text box while running the game

1 answer

I can't see much of what's going on, but make sure that your "TextV" is a NumberValue, and not something different, you can also try converting to number right before changing the walkspeed if it's not a NumberValue.

function click ()
	local spt = script.Parent.Text
	
	if spt ~= nil then
		script.Parent.TextV.Value = tonumber(spt)
	end
	
	local f = script.Parent.TextV.Value
	print("WalkSpeed Set to: " .. script.Parent.TextV.Value)
script.Parent.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.WalkSpeed = tonumber(f)
end

script.Parent.Button.MouseButton1Click:Connect(click)

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