Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make this change in order onclick?

Asked by
yoshi8080 445 Moderation Voter
9 years ago

All I want is the texture to change once a button is clicked. in my script lets name the table values 1,2,3,4,5 and left makes the value = -1 right makes the value + 1 and if the value was 1 and the left value was clicked, it'll go to five.

local gift = script.Parent.Parent.Gift
local mesh = gift.Mesh
local right = script.Parent.Parent.Right
local click = right.ClickDetector
local id = "rbxassetid://"
local sn = 1
texture = {189783253,189748284,190000485 ,190000265}
function onClicked()        
sn = sn + 1
    if sn > #texture then sn = 1 end
    mesh.TextureId = id..texture[sn]
end
for i=1,#texture do
    print(i)
end

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

Answer this question