I want to know how I can change the text and mesh texture onclick? like for example the left button does "-1" and the right does "+1"
local gift = script.Parent.Parent.Gift local mesh = gift.Mesh local right = script.Parent.Parent.Right local click = right.ClickDetector local text = script.Parent.Parent.InformationBlock infotext = text.InfoGui.InfoText.Parent local id = "rbxassetid://" local sn = 1 texture = {189783253,189748284} function onClicked() sn = sn + 1 if sn > #texture then sn = 1 end mesh.TextureId = id..texture[sn] while wait() do for i=1,#texture do print(i) -- test what shows up if i == 1 then text.InfoGui.InfoText.Text = "Gift 1" print("Gift1") elseif i == 2 then text.InfoGui.InfoText.Text = "Gift 2" print("Gift2") end end end end
The text thing only works once, if it's possible.
This is how I went about it, I left out the portion of the GUI as I was unsure how you had your set up, I hope this helped in some sort?
local ID = "rbxassetid://" local Gifts = { Gift1 = {Name = 'Gift One', Texture = 189783253}, Gift2 = {Name = 'Gift Two', Texture = 189748284} } local GiftOn = 1 local MaxGifts = 2 if game.Workspace:FindFirstChild("Gift") ~= nil then game.Workspace.Gift:remove() end local Gift = Instance.new("Part", game.Workspace) Gift.FormFactor = "Custom" Gift.Size = Vector3.new(2,2,2) Gift.Anchored = true Gift.Name = "Gift" local Mesh = Instance.new("SpecialMesh", Gift) Mesh.MeshType = "FileMesh" Mesh.MeshId = "http://www.roblox.com/asset/?id=1237207" Mesh.TextureId = ID..(Gifts["Gift"..GiftOn].Texture) local ClickDet = Instance.new("ClickDetector", Gift) ClickDet.MaxActivationDistance = 10 function Clicked() GiftOn = GiftOn + 1 if GiftOn > MaxGifts then GiftOn = 1 end Mesh.TextureId = ID..(Gifts["Gift"..GiftOn].Texture) end ClickDet.MouseClick:connect(Clicked)