Simple Script that every time a player clicks on a TV, It cycles threw to the next decal

Hello, I am in need of some help to make a script where a player clicks on a part, it will clycle to the next decal

I have 50 different decals, every time I click on a button, I want to to change to the next decal

Example: If I am on decal number 10, when I click the button again, I want it to switch to decal number 11

I’ve tried many different ways I can think of to solve this, but my knowledge of scripting isn’t that great so nothing was successful

If anyone could help me make this or have any ideas for me to try out, please leave them in the comments, Thank you!

local DecalsFolder = script  --Change this to your decals folder
local ChangeDecal = script.Parent:WaitForChild("Decal") -- Change this to your decal that gonna be changed
local ClickDetector = script.Parent:WaitForChild("ClickDetector") -- Changed this to your click detector

local MaxDecals = #DecalsFolder:GetChildren()
local CurrentDecal = 0

ClickDetector.MouseClick:Connect(function(Player)
	CurrentDecal = CurrentDecal + 1
	if CurrentDecal > MaxDecals then
		CurrentDecal = 1
	end
	ChangeDecal.Texture = script:GetChildren()[CurrentDecal].Texture
end)

https://gyazo.com/0905b88be83e82433fd7d15c1862d3ac

2 Likes

Thank you so much! Just one last question, when you say decals folder, what do you mean exactly?

DecalsFolder is where i’ve putted every decals in it here is an example: https://gyazo.com/1dd1fd8968f69e1e8a82c3721d2e28c2

Got it! Thank you so much! :smiley:

1 Like