GUI Tweening Problem

Hello! I’m trying to create death screen where once the player dies, a text label comes across having a bouncing effect. Here’s my script so far:

local diedText = script.Parent.DIEDtext
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Died:Connect(function()
    diedText:TweenPosition(UDim2.new(0.8,0,0.5,0), "In", "Sine", 0.3)
    diedText:TweenPosition(UDim2.new(0.4,0,0.5,0), "In", "Linear", 0.3)
    diedText:TweenPosition(UDim2.new(0.55,0,0.5,0), "In", "Linear", 0.3)
    diedText:TweenPosition(UDim2.new(0.47,0,0.5,0), "In", "Linear", 0.3)
    diedText:TweenPosition(UDim2.new(0.52,0,0.5,0), "In", "Linear", 0.3)
    diedText:TweenPosition(UDim2.new(0.49,0,0.5,0), "In", "Linear", 0.3)
    diedText:TweenPosition(UDim2.new(0.505,0,0.5,0), "In", "Linear", 0.3)
    diedText:TweenPosition(UDim2.new(0.502,0,0.5,0), "In", "Linear", 0.3)
    diedText:TweenPosition(UDim2.new(0.499,0,0.5,0), "In", "Linear", 0.3)
    diedText:TweenPosition(UDim2.new(0.5,0,0.5,0), "In", "Linear", 0.3)
end)

Here’s the video that I’m trying to replicate (by the way, I’m only trying to do the “DIED!” text):

You might be asking, “Well, what’s the problem?”. My problem is that it only plays the first line of code inside of the function. In addition to that, I’m not getting any errors in the output tab. So basically, the text label just stops at (0.8, 0, 0.5, 0). I’m also an “advanced” beginner in Roblox Lua.

Looks like your code is making a bounce effect. Why don’t you just do 1 tween but replace Linear with Bounce?
Also, I think this belongs to #help-and-feedback:scripting-support

From my knowledge, tweening doesn’t pause the thread while it’s running. To debug, try adding a wait(0.3) at the end of each Tween line

Here I made this code for you: (please note there might be better solutions)

local Keyframes = {
['1'] = { UDim2.new(0.8,0,0.5,0), "In", "Sine", 0.3},
['2'] = { UDim2.new(0.4,0,0.5,0), "In", "Linear", 0.3 },
['3'] = { UDim2.new(0.55,0,0.5,0), "In", "Linear", 0.3 },
['4'] = { UDim2.new(0.47,0,0.5,0), "In", "Linear", 0.3 },
['5'] = { UDim2.new(0.52,0,0.5,0), "In", "Linear", 0.3 },
['6'] = { UDim2.new(0.49,0,0.5,0), "In", "Linear", 0.3 },
['7'] = { UDim2.new(0.505,0,0.5,0), "In", "Linear", 0.3 },
['8'] = { UDim2.new(0.502,0,0.5,0), "In", "Linear", 0.3 },
['9'] = { UDim2.new(0.499,0,0.5,0), "In", "Linear", 0.3 },
['10'] = { UDim2.new(0.5,0,0.5,0), "In", "Linear", 0.3 }
}

function PlayTweenSequence(object, keyframes)
for Index, Tween in pairs(keyframes) do
	object:TweenPosition(Tween[1], Tween[2], Tween[3], Tween[4])
	wait(Tween[4])
end
end

Usage:
PlayTweenSequence(diedText, Keyframes)

1 Like

Well, that’s not what I’m trying to do. It’s sort of a custom bounce. I also thought this belongs to the category of scripting, but it’s about the gui as well, soooo.

You might want to implement a custom tween without relying on TweenService.

Of course, there’s open-sourced library for that, check out RoStrap/Tween, that one support beziers, stuff, etc.

Thank you very, very much for the help. I really do appreciate it. By any chance, can I add you if I have any other problems in the future?