UI Tween Not Working [URGENT]

I am trying to create a tween, and everything works well but for some reason the Position. The X of the position should always stay at 0.052

I wan’t the Position to be the one said in the script. (X should be

Help?

local module = {}

function module.Dialouge(UserId)
	
-- You should set the Text
	local DL = game:GetService("ReplicatedStorage"):WaitForChild("Dialouge"):Clone()
	local TS = game:GetService("TweenService")
	local name = game:GetService("Players"):GetNameFromUserIdAsync(UserId)
	
	local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out, 0, false, 0.2)
	
	local TweenOut = TS:Create(DL.SpeechBubble, tweenInfo, {Position = UDim2.new({0.052, 0},{0.138, 0})})
	
	local TweenIn = TS:Create(DL.SpeechBubble, tweenInfo, {Position = UDim2.new({0.052, 0},{-0.165, 0})})
	
	DL.Parent = game:GetService("Players")[name].PlayerGui
	

	
TweenIn:Play()
game:GetService("SoundService").Talk.Playing = true
task.wait(800) -- 8
TweenOut:Play()
TweenOut.Completed:Connect(function()
	DL:Destroy()
	
end)
end

return module

Could I get a video of how the tween is working currently?

I’m unsure on how I can take a video without using the Studios video thing
Would it be fine If I used an app to animate how it acts/looks like?

It looks like there might be a small error in the way you’re specifying the initial position in the TweenOut and TweenIn tweens. Here try this instead

local module = {}

function module.Dialouge(UserId)
    -- You should set the Text
    local DL = game:GetService("ReplicatedStorage"):WaitForChild("Dialouge"):Clone()
    local TS = game:GetService("TweenService")
    local name = game:GetService("Players"):GetNameFromUserIdAsync(UserId)

    local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out, 0, false, 0.2)

    local TweenOut = TS:Create(DL.SpeechBubble, tweenInfo, {Position = UDim2.new(0.052, 0, 0.138, 0)})

    local TweenIn = TS:Create(DL.SpeechBubble, tweenInfo, {Position = UDim2.new(0.052, 0, -0.165, 0)})

    DL.Parent = game:GetService("Players")[name].PlayerGui

    TweenIn:Play()
    game:GetService("SoundService").Talk.Playing = true
    task.wait(8) -- 8 seconds
    TweenOut:Play()

    TweenOut.Completed:Connect(function()
        DL:Destroy()
    end)
end

return module

I modified the argument passed to UDim2.new for Position . Instead of using a table with curly braces {} I provided two separate arguments for X and Y directly inside the UDim2.new function. Im pretty sure this is the correct syntax for specifying the position in a UDim2 object.

I modified the script to this it’s pretty simple

Tween script:

local module = {}

function module.Dialouge(UserId)
    local DL = game:GetService("ReplicatedStorage"):WaitForChild("Dialouge"):Clone()
    local TS = game:GetService("TweenService")
    local name = game:GetService("Players"):GetNameFromUserIdAsync(UserId)

    local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out, 0, false, 0.2)

    local initialPosition = UDim2.new(0.052, 0, -0.165, 0)
    local finalPosition = UDim2.new(0.052, 0, 0.138, 0)

    local TweenIn = TS:Create(DL.SpeechBubble, tweenInfo, { Position = finalPosition })
    local TweenOut = TS:Create(DL.SpeechBubble, tweenInfo, { Position = initialPosition })

    DL.Parent = game:GetService("Players")[name].PlayerGui

    TweenIn:Play()
    game:GetService("SoundService").Talk.Playing = true
    task.wait(800)

    TweenOut:Play()
    TweenOut.Completed:Connect(function()
        DL:Destroy()
    end)
end

return module

In this modification, I’ve set initialPosition to start with a Y position of -0.165 and finalPosition to end with a Y position of 0.138 . The X position (0.052 ) remains constant throughout the tweening process. Adjust the values according to your design preferences and requirements.

1 Like

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