My script doesnt work

  1. 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

  2. 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)

Hi there,
can u give some more information (screenshots from your output and train model in the explorer)

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)

3 questions

where is your gui?
is your script a LocalScript or a ServerScript?
where is your script?

To awnser your questions:
when my train touches the V50 part the ooutput is empty


And pictures of explorer
image


Hope it helps

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

Reply back if the script doesn’t work.

thanks it works! I’ve also used playergui to edit it instead of regular gui and now it works!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.