How do I clone a text button to a specific position on the screen? Thanks! This is my code:
local purchases = game.Players.LocalPlayer.leaderstats.Purchases local cloned = game.ReplicatedStorage.Tools.Desert:Clone() purchases.Changed:Connect(function() if purchases.Value == 1 then print("Hi") script.Parent.Visible = true cloned.Parent = game.Startergui.ScreenGui.Frame1 cloned.Position - ("0.415, 0,0.116, 0") else print("Bye") script.Parent.Visible = false end end)
i would fixed that script :\
local purchases = game.Players.LocalPlayer.leaderstats.Purchases local cloned = game.ReplicatedStorage.Tools.Desert:Clone() purchases.Changed:Connect(function() if purchases.Value == 1 then print("Hi") script.Parent.Visible = true cloned.Parent = game.Startergui.ScreenGui.Frame1 cloned.Position - UDim2.new("0.415, 0,0.116, 0") else print("Bye") script.Parent.Visible = false end end)
Changes: UDim2.new()
So first of all, I'm assuming that cloned
variable is a TextButton or ImageButton in that Tools folder. So let's start.
Line 12, you set the parent. So, this cloned thing is now a child of the Frame1. So, there are questions to solve this problem.
**Is it visible? ** If it's not, then its Visible
property is set to false. Its default position is the middle of the screen. So do cloned.Visible = true
**How do I move it to a certain location? ** Pretty easy. You have to change its Vector3
. If it was a 3D object you had to change its CFrame
but it's a Button now so cloned.Vector3 = location
. You can do (example) local location = Vector3.new(1,5,6)
above the cloned.Vector3, or you can do it directly, cloned.Vector3 = Vector3.new(1,5,6)
So this should work now. However you can move it like it's animated with cloned:TweenPosition()
(you can also do this with frames). Hope I didn't make any mistake.
Probably this:
local Text = script.Parent.TextButton function Click() Text:Clone() Text.Position = UDim2.new(x,y,z) end) Text.Click:connect(Click)
To gloveshun.
local purchases = game.Players.LocalPlayer.leaderstats.Purchases local cloned = game.ReplicatedStorage.Tools.Desert:Clone() purchases.Changed:Connect(function() if purchases.Value == 1 then print("Hi") script.Parent.Visible = true cloned.Parent = game.Startergui.ScreenGui.Frame1 cloned.Position - UDim2.new(0.415, 0,0.116, 0) else print("Bye") script.Parent.Visible = false end end)
Changes: UDim2.new("0.415, 0,0.116, 0") to UDim2.new(0.415, 0,0.116, 0)
You shouldn't use quotation marks because that turns it into a string.