#textbox gui value to vehicle seat properties

54 messages · Page 1 of 1 (latest)

bright hawk
#

i re wrote the script like this
'''Lua
local TurnS = script.Parent.Display.SpeedGUI.GUIGiver.VehicleSeat

local setTurnSpeedButton = TurnS.FocusLost:Connect(function()
local vehicleSeat = TurnS.Parent.Parent.Parent:FindFirstChildOfClass("VehicleSeat")
if vehicleSeat then
local turnSpeed = tonumber(TurnS.Text)
if turnSpeed then
vehicleSeat:SetTurnSpeed(turnSpeed)
else
warn("Invalid value for TurnS:", TurnS.Text)
end
else
warn("Could not find VehicleSeat parent")
end
end)
'''

#

Granted I'm on mobile so the formating of it isn't working

#

I could put it in a txt file but I'm busy ish

glossy hinge
#

ok

#

formatting uses ` not ' but ok

#

That should work.

#

show output @bright hawk

bright hawk
bright hawk
glossy hinge
#

for the codeblocks, use 3 consistant `s

  local output = "Like this"
  print(output)
scenic briar
#

you gotta parse it as number, tonumber("string")

bright hawk
#

Ah I see

#

So I need to tell it that the response is only gonna be a number and that if I put in a letter it's invalid?

bright hawk
#

lemme send a screenshot of the workspace

#

this is the order of everything

#

i think i know the issue

glossy hinge
#

ah I see

bright hawk
#

i think im an idiot

glossy hinge
#

display isnt a member of the textbox

#

"TurnS"

bright hawk
#

oh god

#

im an

#

bruh

#

i know the issue now

#

i just

#

fuck

#

i dont know how to fix it

#

well

#

i found a lazy solution but

#

it gave me another error now

#

refering to this line of code

#
local setTurnSpeedButton = TurnS.FocusLost:Connect(function()
#

can anyone cure my stupidity?

glossy hinge
bright hawk
#
local TurnS = script.Parent.Parent.Parent.Parent

local setTurnSpeedButton = TurnS.FocusLost:Connect(function()
    local vehicleSeat = TurnS.Parent.Parent.Parent:FindFirstChildOfClass("VehicleSeat")
    if vehicleSeat then
        local turnSpeed = tonumber(TurnS.Text)
        if turnSpeed then
            vehicleSeat:SetTurnSpeed(turnSpeed)
        else
            warn("Invalid value for TurnS:", TurnS.Text)
        end
    else
        warn("Could not find VehicleSeat parent")
    end
end)
#

this is what i have rn

#

no idea what to do

#

thinking about pluging it into chat gpt

glossy hinge
#

as an event

#

wouldnt work but

#

bud*

#

you either do a

local setTurnSpeedButton = function()
    local vehicleSeat = TurnS.Parent.Parent.Parent:FindFirstChildOfClass("VehicleSeat")
    if vehicleSeat then
        local turnSpeed = tonumber(TurnS.Text)
        if turnSpeed then
            vehicleSeat:SetTurnSpeed(turnSpeed)
        else
            warn("Invalid value for TurnS:", TurnS.Text)
        end
    else
        warn("Could not find VehicleSeat parent")
    end
end

and

TurnS.FocusLost:Connect(setTurnSpeedButton)
#

or

#

remove the

local SetTurnSpeedButton = 
bright hawk
#

will try it tn

bright hawk
glossy hinge
# bright hawk Not sure what I did but it was printing the second else part

fix 1: ```lua
TurnS.FocusLost:Connect(function()
local vehicleSeat = TurnS.Parent.Parent.Parent:FindFirstChildOfClass("VehicleSeat")
if vehicleSeat then
local turnSpeed = tonumber(TurnS.Text)
if turnSpeed then
vehicleSeat:SetTurnSpeed(turnSpeed)
else
warn("Invalid value for TurnS:", TurnS.Text)
end
else
warn("Could not find VehicleSeat parent")
end
end)

fix 2: 
```lua
local setTurnSpeedButton = function()
    local vehicleSeat = TurnS.Parent.Parent.Parent:FindFirstChildOfClass("VehicleSeat")
    if vehicleSeat then
        local turnSpeed = tonumber(TurnS.Text)
        if turnSpeed then
            vehicleSeat:SetTurnSpeed(turnSpeed)
        else
            warn("Invalid value for TurnS:", TurnS.Text)
        end
    else
        warn("Could not find VehicleSeat parent")
    end
end
TurnS.FocusLost:Connect(setTurnSpeedButton)
dense notchBOT
#

studio** You are now Level 6! **studio

bright hawk
#

Gonna test it tonight