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

TextBox.Text tonumber not working?

Asked by
c1m50c 5
5 years ago

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

0
What is the text you are trying to convert to a number? MegaManSam1 207 — 5y
0
What ever is in the text box while running the game c1m50c 5 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
Ad

Answer this question