#TEXT BUTTON NOT CLONING
265 messages · Page 1 of 1 (latest)
put this in the code block
Try parenting the duplicate to a ScreenGui inside the PlayerGui rather than the PlayerGui object directly.
local TextButton = Dupe.Duping
TextButton.MouseButton1Click:Connect(function()
print("Clicked")
local clonedButton = TextButton:Clone()
clonedButton.Position = UDim2.new(0, math.random(0, workspace.CurrentCamera.ViewportSize.X), 0, math.random(0, workspace.CurrentCamera.ViewportSize.Y))
clonedButton.Parent = game.Players.LocalPlayer.PlayerGui
clonedButton.MouseButton1Click:Connect(function()
local newClone = clonedButton:Clone()
newClone.Position = UDim2.new(0, math.random(0, workspace.CurrentCamera.ViewportSize.X), 0, math.random(0, workspace.CurrentCamera.ViewportSize.Y))
newClone.Parent = game.Players.LocalPlayer.PlayerGui
end)
end)
there:```lua
local Dupe = script.Parent
local TextButton = Dupe.Duping
TextButton.MouseButton1Click:Connect(function()
print("Clicked")
local clonedButton = TextButton:Clone()
clonedButton.Position = UDim2.new(0, math.random(0, workspace.CurrentCamera.ViewportSize.X), 0, math.random(0, workspace.CurrentCamera.ViewportSize.Y))
clonedButton.Parent = game.Players.LocalPlayer.PlayerGui
clonedButton.MouseButton1Click:Connect(function()
local newClone = clonedButton:Clone()
newClone.Position = UDim2.new(0, math.random(0, workspace.CurrentCamera.ViewportSize.X), 0, math.random(0, workspace.CurrentCamera.ViewportSize.Y))
newClone.Parent = game.Players.LocalPlayer.PlayerGui
end)
end)
makes it easier to help you now
basically what this script should do is when i click a text button on my screen it will print("clicked") and clone itself on random places on the players screen
is*
ah
the clicked bit works
very simple then
so math . random works?
easy fix
local clone = script.Parent.Duping
local x = false
local ran = math.random(0,400) -- randomizer
local ran2 = math.random(0,400) -- randomizer2
TextButton.MouseButton1Click:Connect(function() -- click
ran = math.random(0,400) -- makes the randomizer change every time so different numbers
ran2 = math.random(0,400) -- makes the randomizer2 change every time so different numbers
if x == false then -- toggle
print("fixed?") -- print you wanted
clonex = clone:Clone() -- clone
clonex.Parent = clone.Parent -- puts the parent (i recommend puting frames in the main gui so less lag)
clonex.Position = Udim2.new(0,ran,0,ran2) -- uses the randomizers to change position
x = true -- toggle active (cant toggle back)
print("Complete") -- print that checks if it completes (if errors then it wont print)
elseif x == true then -- toggle
print("fixed?") -- print you wanted
local clonex2 = clonex:Clone() -- clone
clonex2.Parent = clone.Parent -- puts the parent (i recommend puting frames in the main gui so less lag)
clonex2.Position = Udim2.new(0,ran,0,ran2) -- uses the randomizers to change position
print("Complete") -- print that checks if it completes (if errors then it wont print)
end -- toggle end
end) -- click end
try this @shadow zodiac
may be solution
havent tested it
Alr bet
may be errors as i made it in discord
if there are errors ill fix them
But the problem is anytime I make a cloning script
Its fine I know how it works now
I read the script
so you can repeat it whenever
also can you help me with random generation
cuz
anytime i make cloning scripts
it always on a part of the player screen
i just want it so it can show up anywhere on the players screen
TRY CHANGE RAN VARIABLE TO 800 NOT 400
check this
@shadow zodiac
alr
that worked
but how
i dont understand that
ohhh
they r x n y
?
nevermind i understand how that works
alr
thanks @amber cloud @thick notch
btw its best to do things and add tags so its easier to replicate again and again
alright
CUZ
RAN WAS THE RANDOM X NUMBER
AND SINCE IT SPAWNED ON ONE HALF
THEN IF YOU X2 THE RAN VARIABLE
IT SHOULD SPAWN ON BOTH
IDK HOW TO EXPLAIN
i feel like your caps lock is broken
then why are you screaming 💀
I FEEL AS IF IT IS NECCESARY
you know that right?
because you can do this,
this
this
and this
# because you can do this,
## this
### this
and **this**
WOW
I SEE
YOU KNOW THAT RIGHT
THIS IS COOL
WAIT A MINUTE
OK
OK
OK
OK
WOW
I SEE
@shadow zodiac
local clone = script.Parent.Duping
local x = false
local ran = math.random(0,600) -- randomizer
local ran2 = math.random(0,700) -- randomizer2
TextButton.MouseButton1Click:Connect(function() -- click
ran = math.random(0,600) -- makes the randomizer change every time so different numbers
ran2 = math.random(0,700) -- makes the randomizer2 change every time so different numbers
if x == false then -- toggle
print("fixed?") -- print you wanted
clonex = clone:Clone() -- clone
clonex.Parent = clone.Parent -- puts the parent (i recommend puting frames in the main gui so less lag)
clonex.Position = Udim2.new(0,ran,0,ran2) -- uses the randomizers to change position
x = true -- toggle active (cant toggle back)
print("Complete") -- print that checks if it completes (if errors then it wont print)
elseif x == true then -- toggle
print("fixed?") -- print you wanted
local clonex2 = clonex:Clone() -- clone
clonex2.Parent = clone.Parent -- puts the parent (i recommend puting frames in the main gui so less lag)
clonex2.Position = Udim2.new(0,ran,0,ran2) -- uses the randomizers to change position
print("Complete") -- print that checks if it completes (if errors then it wont print)
end -- toggle end
end) -- click end
do that
Lemme just get it up
?
what
so when you click the original text button it will go invisible and clone
the text doesnt need to become a file??
local dupe = script.Parent
local TextButton = dupe.Duping
-- Clone object and set initial state
local clone = script.Parent.Duping
local currentButton = nil -- Keep track of the currently active TextButton
-- Function to generate a random position within the screen boundaries and random text
local function generateRandomPosition()
local viewportSize = workspace.CurrentCamera.ViewportSize
local posX = math.random(0, viewportSize.X)
local posY = math.random(0, viewportSize.Y)
local randomText = ""
local characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
local randomIndex = math.random(1, #characters)
randomText = string.sub(characters, randomIndex, randomIndex)
return UDim2.new(0, posX, 0, posY), randomText
end
-- Function to handle cloning a new TextButton and removing the last one
local function cloneTextButton(button)
if currentButton then
currentButton:Destroy() -- Remove the currently active TextButton if it exists
end
-- Clone the TextButton
local clonex = clone:Clone()
clonex.Parent = clone.Parent
clonex.Position, clonex.Text = generateRandomPosition() -- Generate a random position and text on the screen
clonex.BackgroundColor3 = Color3.fromRGB(192, 192, 192) -- Set background color to grey
clonex.TextSize = 24 -- Set text size to 24
-- Connect the cloned TextButton's click event to the function
clonex.MouseButton1Click:Connect(function()
cloneTextButton(clonex) -- Clone and remove the clicked button
end)
currentButton = clonex -- Set the current cloned TextButton as the active TextButton
end
-- Function to handle the original TextButton's click event
local function handleOriginalButtonClick()
TextButton.Visible = false -- Make the original TextButton invisible
TextButton.MouseButton1Click:Disconnect() -- Disable further clicks on the original TextButton
cloneTextButton()
end
-- Connect the original TextButton's click event to the function
TextButton.MouseButton1Click:Connect(handleOriginalButtonClick)
oh
nitro
oh
yeah you have nitro
so yeah
i made a lot of changes to the script to do a lot of stuff
what is this
the script?
lord almighty why did I enter this thread
i only gave you this
how
oh i just built upon the fix
im squealing so hard rn im becoming a kettle
wha
what is this ment to do
what have you change
when you click the text button
it spawns a
textbutton
and if you click the textbutton
the last text button
will dissapear
and crrate a new one
create a new one
when you click that
explanation 100
bro it doesnt require that much code
oh i had a feeling i overdid it
bro is like me @ math class

i mean it still works

if it aint broke don't fix it 🤷♂️
well the script has kinda broke ig

pov: u got discord nitro for ur birthday
local x = script.Parent.Frame
local ran = math.random(0,600)
local ran2 = math.random(0,700)
local ran3 = math.random(1,26)
local num = 0
x.Frame.TextButton.MouseButton1Click:Connect(function()
ran = math.random(0,600)
ran2 = math.random(0,700)
ran3 = math.random(1,26)
if ran3 == 1 then
x.Frame.TextButton.Text = "a"
elseif ran3 == 2 then
x.Frame.TextButton.Text = "b"
elseif ran3 == 3 then
x.Frame.TextButton.Text = "c"
elseif ran3 == 4 then
x.Frame.TextButton.Text = "d"
elseif ran3 == 5 then
x.Frame.TextButton.Text = "e"
elseif ran3 == 6 then
x.Frame.TextButton.Text = "f"
elseif ran3 == 7 then
x.Frame.TextButton.Text = "g"
elseif ran3 == 8 then
x.Frame.TextButton.Text = "h"
elseif ran3 == 9 then
x.Frame.TextButton.Text = "i"
elseif ran3 == 10 then
x.Frame.TextButton.Text = "j"
elseif ran3 == 11 then
x.Frame.TextButton.Text = "k"
elseif ran3 == 12 then
x.Frame.TextButton.Text = "l"
elseif ran3 == 13 then
x.Frame.TextButton.Text = "m"
elseif ran3 == 14 then
x.Frame.TextButton.Text = "n"
elseif ran3 == 15 then
x.Frame.TextButton.Text = "o"
elseif ran3 == 16 then
x.Frame.TextButton.Text = "p"
elseif ran3 == 17 then
x.Frame.TextButton.Text = "q"
elseif ran3 == 18 then
x.Frame.TextButton.Text = "r"
elseif ran3 == 19 then
x.Frame.TextButton.Text = "s"
elseif ran3 == 20 then
x.Frame.TextButton.Text = "t"
elseif ran3 == 21 then
x.Frame.TextButton.Text = "u"
elseif ran3 == 22 then
x.Frame.TextButton.Text = "v"
elseif ran3 == 23 then
x.Frame.TextButton.Text = "w"
elseif ran3 == 24 then
x.Frame.TextButton.Text = "x"
elseif ran3 == 25 then
x.Frame.TextButton.Text = "y"
elseif ran3 == 26 then
x.Frame.TextButton.Text = "z"
end
x.Visible = false
num += 1
wait(0.2)
x.Position = UDim2.new(0,ran,0,ran2)
print(num)
end)
@shadow zodiac
@shadow zodiac ?
code ^^
wait what im tryna make it is like click the buttons and meditate
something like that
acc lemme send a screen recording
i just wanna get rid of white box when u click it
but i jave tried many different spproches like making the boxing invisible destroying it n more
how many letters in the alphabet
i think 52 which includes capitals
no caps
26
@shadow zodiac
check this now
uh what does this script exactly do
the position of whatt
the text
wait you do know what i need help with right
the white button just to dissapear when i click it and it clones a button
alr
now i think about it
i'm an idiot
instead of clonning
i could of made a script that would move the text button when you clicked it
thats what that does
nope
so i need to make everything match up to the script
alr
ok
so
something works
well
it kinda works
because it does move
but i think its moving of the players screen
local ran = math.random(0, 600)
local ran2 = math.random(0, 700)
local letters = {
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
}
x.Frame.TextButton.MouseButton1Click:Connect(function()
ran = math.random(0, 600)
ran2 = math.random(0, 700)
local ran3 = math.random(1, 26)
x.Frame.TextButton.Text = letters[ran3]
x.Visible = false
wait(0.2)
x.Position = UDim2.new(0, ran, 0, ran2)
end)
also put it in a table
cuz the elseif were making my head hurt
Ah yeah
sos
its cuz i have kinda quit deving a lil
rn
and i havent coded my discord bot in a while
local textButton = script.Parent
-- Function to move the object to a random position
local function moveObject()
local parentSize = textButton.Parent.AbsoluteSize
local buttonSize = textButton.AbsoluteSize
-- Calculate the valid range for positioning
local minX = 0
local maxX = parentSize.X - buttonSize.X
local minY = 0
local maxY = parentSize.Y - buttonSize.Y
-- Generate random coordinates within the valid range
local randomX = math.random(minX, maxX)
local randomY = math.random(minY, maxY)
-- Set the position using the random coordinates
textButton.Position = UDim2.new(0, randomX, 0, randomY)
end
-- Connect the function to the TextButton's click event
textButton.MouseButton1Click:Connect(moveObject)



