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

GuiObject's position is stated, but it doesn't go to the position?

Asked by
Rzmin 0
4 years ago

Hey there! I need just a little help on what I am doing wrong, I am hoping to have a textlabel that states you have gotten 1 extra cash when clicked, the function states the instance and it's position, but in-game, the position goes to the corner of the screen (0,0,0,0). I also want the gui's position to be randomly spread across the screen, hence the math.random.

Here's the function!

function MakeNewGui()

    local gui = Instance.new("TextLabel")
    gui.Parent = game.Players.LocalPlayer.PlayerGui.Cash_Popup
    gui.Name = ("Cash_Given")
    gui.Text = ("+1 Cash")
    gui.TextScaled = true
    gui.BackgroundTransparency = 1
    gui.Size = UDim2.new(0, 200,0, 50)
    gui.Position = UDim2.new(0, math.random(30,70) / 100,0, math.random(30,70) / 100)
    gui.TextColor3 = Color3.new(83, 137, 207)
    gui:TweenSizeAndPosition((gui.Position),UDim2.new(0.5,0,0.5,0), 0.01)

    wait(1)

    gui:Destroy()
end

Answer this question