Making click to change texture id

I want to make it so when i click my car it will change the scheme but my script is not working
These are the 3 designs i want it to cycle through when you click it:
But then when i click i only get the primary one:

How do i fix this

  1. What do you want to achieve? I want to change the car scheme when i click it

  2. What is the issue? It doesnt change when i click on it

  3. What solutions have you tried so far? I tried “if __ then” but it still didnt work

This is the script i have for it:

The system uses a click detector to change the design

1 Like

Your code is redefining the texture instantly for all 3. I’m assuming you want it to only change when clicked every single time:

myTextures = {
	[1] = "FirstTexture",
	[2] = "SecondTexture",
	[3] = "ThirdTexture"
iteration = 1

function onClicked()
	iteration +=1
	if iteration > 3 then 
		iteration = 0
	car.TextureID = iteration
1 Like

I got it to work with a different script but thank you for the help…

1 Like

You should mark their post as the solution (in case anyone visits this thread looking for one).