-
Im trying to make a variable equal two objects for a script using the touch function to modify a value
in a GUI -
ive tried using or for it but it doesnt work
-
ive looked on the dev hub and it shows that you can use iterating with i pairs but i dont understand
how that works and im not sure if it would work with the touch function
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!
im only pasting the parts of the script that do the function described earliers as the rest of the script is just speed calculations
Variables
-- bin = script.Parent
Sensorpart = bin.Sensor or bin.Parent._4.Sensor
eng = { }
st = bin.VehicleSeat
msp = script.MaximumSpeed.Value
st.MaxSpeed = msp
mrs = script.MaximumReverseSpeed.Value --> Maximum Reverse Speed
spt = script.SpeedPerThrottle.Value --> Speed Per Throttle. This is how much each notch on the throttle changes
mxt = math.ceil(msp / spt) --> This is the maximum throttle
crt = 0 --> Current throttle
csd = 0 --> Current speed
cdr = 1 --> Current direction
drive = false --> Is the train driving. False = not driving, true = driving
plr = nil --> This will change to the current driver
DirTable = {"Reverse", "Neutral", "Foward"}
TrtStp =1 --> This is used so there is a second or 2 gap in between changing the throttle.
code that modify the gui
Sensorpart.Touched:Connect(function(child)
if child:IsA('Part') then
task.wait(0.5)
if child.Name == "V30" then
h2.MainDriving.Manipulateur.Max.Text = "30"
elseif child.Name == "V50" then
h2.MainDriving.Manipulateur.Max.Text = "50"
elseif child.Name == "V60" then
h2.MainDriving.Manipulateur.Max.Text = "60"
elseif child.Name == "V80" then
h2.MainDriving.Manipulateur.Max.Text = "80"
elseif child.Name == "V90" then
h2.MainDriving.Manipulateur.Max.Text = "90"
elseif child.Name == "V100" then
h2.MainDriving.Manipulateur.Max.Text = "100"
end
end
end)