#TEXT BUTTON NOT CLONING

265 messages · Page 1 of 1 (latest)

amber cloud
#

@shadow zodiac

shadow zodiac
#

hyh

#

hyh

#

huh

#

hi?

#

oh

amber cloud
#

put this in the code block

shadow zodiac
#

nvm hi

#

i dont think a simple print("hi") will fix my issue

amber cloud
#

ik

#

but put that code in a code block

#

makes it easier to help you

shadow zodiac
#

ohh

#

ok

unique gale
#

Try parenting the duplicate to a ScreenGui inside the PlayerGui rather than the PlayerGui object directly.

shadow zodiac
#
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)
amber cloud
#

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

shadow zodiac
#

ohh tjamks

#

thanks

amber cloud
#

so explain

#

what are you trying to do

shadow zodiac
#

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*

amber cloud
#

ah

shadow zodiac
#

the clicked bit works

amber cloud
#

very simple then

shadow zodiac
#

which was my debug

#

yeah

#

its simple but id why its not woring

#

working

amber cloud
#

so math . random works?

shadow zodiac
#

everythung underneath click does not work

#

everything

amber cloud
#

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

shadow zodiac
#

Alr bet

amber cloud
#

may be errors as i made it in discord

shadow zodiac
#

if there are errors ill fix them

amber cloud
#

alr

#

or ask me if you cant

shadow zodiac
#

There was an error I fixed it now it works

#

Thanks

#

🙏🏾

amber cloud
#

no problem

#

also ill edit itso it explains how it works

shadow zodiac
#

But the problem is anytime I make a cloning script

shadow zodiac
#

I read the script

amber cloud
#

so you can repeat it whenever

shadow zodiac
#

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

thick notch
#

TRY CHANGE RAN VARIABLE TO 800 NOT 400

shadow zodiac
#

alr

shadow zodiac
#

but how

#

i dont understand that

amber cloud
#

?

shadow zodiac
#

nevermind i understand how that works

amber cloud
#

alr

shadow zodiac
#

thanks @amber cloud @thick notch

amber cloud
#

btw its best to do things and add tags so its easier to replicate again and again

shadow zodiac
#

alright

thick notch
#

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

amber cloud
thick notch
#

NO

#

ITS NOT

amber cloud
#

then why are you screaming 💀

thick notch
amber cloud
#

uh

#

you could just do this though??

amber cloud
#

because you can do this,

this

this

and this

#
# because you can do this,
## this
### this
and **this**
thick notch
#

WOW

#

I SEE

#

YOU KNOW THAT RIGHT

#

THIS IS COOL

#

WAIT A MINUTE

#
OK
#

OK

#

OK

#

OK

#

WOW

#

I SEE

shadow zodiac
#

###yippee

#

yippee

#

yippee

#

this

shadow zodiac
#

@amber cloud

#

the random feature didnt work

#

i thought it did

#

i fixed it

amber cloud
#

@shadow zodiac

shadow zodiac
#

Hi

#

I have a new problem

amber cloud
#
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

shadow zodiac
#

I fixed my old one

#

I fixed it

#

Dw

amber cloud
#

random fills the screne

#

problem?

shadow zodiac
#

Lemme just get it up

amber cloud
#

?

shadow zodiac
#

so basically i made it

amber cloud
#

what

shadow zodiac
#

so when you click the original text button it will go invisible and clone

amber cloud
#

is that

#

????

shadow zodiac
#

but the clone factor doesnt work

#

what is what

#

the script?

amber cloud
#

the text doesnt need to become a file??

shadow zodiac
#

because the script is more than 2k words

#

theres a limit

amber cloud
#
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)
shadow zodiac
#

oh

amber cloud
#

nitro

shadow zodiac
#

oh

#

yeah you have nitro

#

so yeah

#

i made a lot of changes to the script to do a lot of stuff

amber cloud
#

what is this

shadow zodiac
#

the script?

fallow pivot
#

lord almighty why did I enter this thread

shadow zodiac
#

oh i just built upon the fix

amber cloud
#

im squealing so hard rn im becoming a kettle

shadow zodiac
#

did i do something wrong

#

cuz

amber cloud
#

wha

shadow zodiac
#

i used used ur fix as a guide

#

cuz i knew how to make everything

amber cloud
#

what is this ment to do

shadow zodiac
#

what the script basically does

#

is

amber cloud
#

what have you change

shadow zodiac
#

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

fallow pivot
#

explanation 100

amber cloud
#

bro it doesnt require that much code

shadow zodiac
amber cloud
#

yeah

#

yeah

#

just a lil hahaOOP

fallow pivot
#

bro is like me @ math class

amber cloud
shadow zodiac
#

i mean it still works

amber cloud
fallow pivot
#

if it aint broke don't fix it 🤷‍♂️

amber cloud
shadow zodiac
#

well the script has kinda broke ig

amber cloud
fallow pivot
#

pov: u got discord nitro for ur birthday

amber cloud
#

wrong

#

/e dance

#

anyways

#

time to fix

#

...

shadow zodiac
#

my bad i did go to far

#

too

amber cloud
#
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 ?

shadow zodiac
#

hi

#

what happened

shadow zodiac
#

would that change the clones

#

ohh

#

what

amber cloud
#

you dont need to clone it

#

if you only want 1

shadow zodiac
#

wait what im tryna make it is like click the buttons and meditate

#

something like that

#

acc lemme send a screen recording

amber cloud
#

edited

#

@shadow zodiac

shadow zodiac
#

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

amber cloud
#

how many letters in the alphabet

shadow zodiac
#

i think 52 which includes capitals

amber cloud
#

no caps

shadow zodiac
#

26

amber cloud
#

@shadow zodiac

shadow zodiac
#

Alr

#

I'm eating rn

#

I'll check it out in 10 mins

#

alr

#

lemm check it out

shadow zodiac
amber cloud
#

text to a to z and regular code

#

that moves the position

shadow zodiac
#

the position of whatt

amber cloud
#

the text

shadow zodiac
#

wait you do know what i need help with right

amber cloud
#

well button

#

?

#

@shadow zodiac ?

shadow zodiac
#

the white button just to dissapear when i click it and it clones a button

amber cloud
#

just try this mode

#

code*

shadow zodiac
#

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

shadow zodiac
#

oh

#

does it create

#

a frame?

amber cloud
#

nope

shadow zodiac
#

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

amber cloud
#

Ah yeah

#

sos

#

its cuz i have kinda quit deving a lil

#

rn

#

and i havent coded my discord bot in a while

shadow zodiac
#

its fine

#

you have done enough

#

i think i can fix

#

the ossue

#

issue

shadow zodiac
#
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)