Adding a number to an int value

Im trying to make a controllable train, and to do that im using simple parts in the cab that the player can click, that then change a value. The value works, the engine can read it and adjust its speed fine, but cant get the value to change, I’ve looked everywhere, even tried Discord, nothing. Also, side note, this is my first ever time messing with values.

function onClicked()
	script.Parent.Parent.Parent.Speed.Value = script.Parent.Parent.Parent.Speed.Value + 10
end 

script.Parent.ClickDetector.MouseClick:connect(onClicked)

This is all I have so far, any ideas would be cool
ahhhhh
structure tree.

3 Likes

The ClickDetector is located in script.Parent.Parent, not script.Parent.

Other than that, your script seems fine. Just make sure to use :Connect instead of :connect.

3 Likes

Just a classic case of me being dumb, thank you

1 Like