Can't change Decal when I clicked on

I scripted the Decal that clicks to change it:

local Face = script.Parent

local Decal = Face.Decal

local Value = Face.Value

local Click = Face.ClickDetector

local function Action()

if Value.Value == 1 then

Decal.Texture = "http://www.roblox.com/asset/?id=11307771110"

elseif Value.Value == 2 then

Decal.Texture = "http://www.roblox.com/asset/?id=11338363339"

elseif Value.Value == 3 then

Decal.Texture = "http://www.roblox.com/asset/?id=11338363357"

end

end

local function Next()

if Value.Value == 1 then

Value.Value = 2

elseif Value.Value == 2 then

Value.Value = 3

elseif Value.Value == 3 then

Value.Value = 1

end

Action()

end

Action()

Click.MouseClick:Connect(Next)

I’m already scripted, but look it doesn’t work for decal changer:

In the video, how do I script that click to change decal?

2 Likes

Here is a solution

The ; Semi-Colon is not important, it just something i added.

I try to organize my scripts, it kind of became a habit of mine.

Dont get Overwhelmed by the --Comments, They are just there for better understanding

Face = script.Parent;
Decal = Face.Decal;
Click = Face.ClickDetector;

FaceNumber = 0; -- Number Value for our textures, Set to 0 indicating that there will be no change unless told to change within this table below

Textures = { -- Our Table of Textures (Since this table has Variables, its now known as a Dictionary)
[1] = "http://www.roblox.com/asset/?id=11307771110", -- Organizes the Dictionary into a number order, Will be used later
[2] = "http://www.roblox.com/asset/?id=11338363339",
[3] = "http://www.roblox.com/asset/?id=11338363357"
};

Click.MouseClick:Connect(function()
FaceNumber += 1 -- Adds the number
Decal.Texture = Textures[FaceNumber] -- Changes Texture to the Following Number in Table using FaceNumber
print(FaceNumber) -- Prints the number (Not Important but used for Testing an Debugging)

if FaceNumber >= 3 then -- Checks if number is greater than or equal to 3, if so then it changes it back to 0
FaceNumber = 0
end
end);

It doesnt require that much, ive had the same problem like you when i first started coding on Roblox