My script is supposed to chose a random gradient from a folder of ones that I made. The first time it choses a gradient but then it sticks with it the after the gui is opened again, why is this?
This choses the gradient:
local gradClone function chooseGradient(player) local gradients = game.ReplicatedStorage.UI.PhoneGradients:GetChildren() local randomGradient = gradients[math.random(1,#gradients)] gradClone = randomGradient:Clone() gradClone.Parent = player.PlayerGui.PhoneMenuGui.MainFrame.ScreenFrame end
This destroys it when the gui is closed:
function closePhone(player) local playerGui = player:WaitForChild("PlayerGui") playerGui.PhoneMenuGui.MainFrame:TweenPosition( UDim2.new(-0.189, 0, 0.262, 0), -- End position "Out", -- Easing direction "Linear", -- Easing style 0.5, -- Time in seconds false, -- Overide other tweens print("Phone closed"), gradClone:Destroy() ) end