Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

is this possible?, i want to make each text label go to the spot but i dont know if its possible

i want to put the text label in the desired spot but i dont know if its possible this is my script

local h = 1

script.Parent.MouseButton1Down:Connect(function()

print("pressed")

local newf = Instance.new("TextLabel",game.StarterGui.ScreenGui)

newf.Name = (h)

h = h+1 

print(h)

h.position == {0,0},{0,0,0}

end)

ive also tried

local h = 1

script.Parent.MouseButton1Down:Connect(function()

print("pressed")

local newf = Instance.new("TextLabel",game.StarterGui.ScreenGui)

newf.Name = (h)

h = h+1 

print(h)

(h).position == {0,0},{0,0,0}

end)

4 comments

0

Your script isn't possible whatsoever. You logic regarding "h" would never be possible either.

0

You must spawn the Instance in the active user-interface, which is PlayerGui, not StarterGui.

0

Using parentheses is redundant.

0

To adjust a UI Instance's position, you need to give it a UDim2.

1 answer

No it's not possible the way you're doing it. All contents of StarterGui replicate to PlayerGui, so you'll need to access it there, however if you were to do it via StarterGui, the player would need to reset I believe for the gui instances to show.

Moreover, to position any gui object, you would need to use Udim2. Udim2 has 4 parameters: xScale, xOffset, yScale, yOffset

local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui") -- Wait for playerGui to load in

script.Parent.MouseButton1Down:Connect(function()
	local newf = Instance.new("TextLabel", playerGui.ScreenGui) -- Access ScreenGui from playerGui
	newf.Position = UDim2.new(0, 0, 0, 0)
end)

I recommend you read over these articles: https://developer.roblox.com/en-us/api-reference/datatype/UDim2

https://developer.roblox.com/en-us/api-reference/property/GuiObject/Position

https://developer.roblox.com/en-us/api-reference/class/StarterGui

This discussion is preserved as it was. New answers, comments, and votes are closed.