Im making a script where if a sensor part touches a part named V50 in this case it changes the text in my train gui to 50
the script doesnt work and nothing in the output helps but when i make the function do something else it works
-- local Gui = script.Parent.Parent.Controli.Dualis.MainDriving.Manipulateur
script.Parent.Touched:Connect(function(child)
if (child.Name == "V50") then
Gui.Max.Text = "oui"
end
end)
I do need more information but try this, it could be the brackets, also where is this script in?
– local Gui = script.Parent.Parent.Controli.Dualis.MainDriving.Manipulateur
script.Parent.Touched:Connect(function(hit)
if hit.Name == “V50” then
Gui.Max.Text = “oui”
end
end)
@deezychesse, is the sensor part the part that moves with the train? Also, is the script provided inside the sensor part?
Assuming that this is all correct, then try this script:
local Gui = script.Parent.Parent.Controli.Dualis.MainDriving.Manipulateur
local Sensorpart = script.Parent
Sensorpart.Touched:Connect(function(child)
if child:IsA("Part") then
task.wait(0.5) --This should also stop the infinte yeild warning on ':FindFirstChild'.
if child.Name == "V50" then
Gui:FindFirstChild("Max").Text = "50"
end
end
end)