GUI's Y position cannot be changed with tweening

I’m trying to make a GUI tween after it has spawned, and having different Y positions as it spawns. The Y value will always be the same for some reason, and so the tween can’t tween the value.

The GUI is a textlabel, though it didn’t work with imagelabel either when I tried.
I can edit the Y value manually when in-game. No errors.
Weirdly, the X value will be stuck at top left if the Y value isn’t changed.

UI paths
image

Cloning in Local Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEffect = game.ReplicatedStorage.remoteEffect

local function onClone(player)
	local random = math.random(1,900)
	local xnew = random/1000
	local new = game.ReplicatedStorage.data:Clone()
	new.Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui1
	new.Position = UDim2.new(xnew,0,math.random(0.1,0.5),0)
end

remoteEffect.OnClientEvent:Connect(onClone)

Effect in a different Local Script:

task.wait(0.1)
script.Parent:TweenPosition(UDim2.new(script.Parent.Position.X,0,1,0))

for i = 1,40 do
	script.Parent.TextTransparency = script.Parent.TextTransparency + 0.04
	wait(0.05)
end

game["Run Service"].RenderStepped:Connect(function()
	if script.Parent.TextTransparency >= 1 then
	script.Parent:Destroy()
	end
end)

try using Random.new

example:

local ran = Random.new()
local number = ran:NextNumber(0.1, 0.5)

print(number) --> 0.3

math.random only works with integers.

2 Likes

nice, that does work for the cloning script.
Do know why it can only tween to a specific value (top of the screen)?

task.wait(0.1)
script.Parent:TweenPosition(UDim2.new(script.Parent.Position.X,0,(any value),0))

Looks like the same issue in this post, however the solution requires removing the X value altogether which just gives a new issue of the X value being incorrect.

Edit: Ok the solution is to add .Scale on the X value (but not the Y value). I’m going to give the solution check to TheNamesLua for fixing the first issue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.