QufioixDev
(DeletedUser)
April 8, 2021, 11:59pm
#1
I was working on a textbox that changes you’re walkspeed to whatever number is in the textbox I tried to do that but nothing would happen.
script.Parent.Focused:Connect(function(enter)
if enter then
Plr.Character.Humanoid.WalkSpeed = script.Parent.Text
end
end
Don’t know what to do right now so…
1 Like
Do this:
script.Parent.Focused:Connect(function(enter)
if enter then
Plr.Character.Humanoid.WalkSpeed = tonumber(script.Parent.Text)
end
end
QufioixDev
(DeletedUser)
April 9, 2021, 12:06am
#3
That didn’t work either no errors printed
Instead of using the Focused
event, use the FocusLost
one instead:
script.Parent.FocusLost:Connect(function(enter)
print("Lost focus")
if enter then
print("Entered result")
Plr.Character.Humanoid.WalkSpeed = tonumber(script.Parent.Text)
end
end
In addition to what @JackscarIitt said, you should probably add a pcall or something to make sure the player entered a number.
local num
xpcall(function()
num = tonumber(script.Parent.Text)
end, function(err)
warn("Error; "..err)
end)
QufioixDev
(DeletedUser)
April 9, 2021, 12:13am
#6
Thanks man, I was going at that for a while now.
You’re fine! Just keep in mind that the Focused
event does not have any parameters (Or the “enter” variable you used)
FocusLost
does however, as I referenced earlier
JackscarIitt:
1 Like