Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Move GUI's around to random positions?

Asked by
haba_nero 386 Moderation Voter
5 years ago

I tried this but the coords end up wrong. I am trying to make it show a text label at a random place every time a player clicks it. It just ends up nowhere!. Pls, help!

local Plr = script.Parent.Parent.Parent
local DB = false
local Sound = script.Parent:FindFirstChild("Sound")
local GUI = game.StarterGui.ScreenGui:FindFirstChild("TextLabel")
script.Parent.Activated:Connect(function()
    if DB == false then
        DB = true

    if Plr then
        local Multi = Plr.HiddenStats:FindFirstChild("Multiplier")
        local Chill = Plr.leaderstats:FindFirstChild("Chill")
        if Multi and Chill then
            Chill.Value = Chill.Value + 1 * Multi.Value
            Sound:Play()

            local Clone = GUI:Clone()
            Clone.Parent = Plr.PlayerGui:FindFirstChild("ScreenGui")
            Clone.Position = UDim2.new(math.random(0,1),0,math.random(0,1),0)--The part that messes up!
            Clone.Visible = true
            Clone.Text = "+"..Multi.Value
            wait(1)
            Clone:Destroy()

        end
    end
    local Delay = Plr.HiddenStats:FindFirstChild("Delay")
    wait(Delay.Value - 1)
    DB = false
    end
end)

1 answer

Log in to vote
1
Answered by
VitroxVox 884 Moderation Voter
5 years ago

Hello so i see your problem

Well i don't really know if this works but try it:

Clone.Position = UDim2.new(0,math.random(0,900), 0,math.random(0,900))
0
uh Psudar 882 — 5y
Ad

Answer this question