Gui Tween Not Working

Im making a script with a tween and everything works fine but theres a second tween that wont run, can anybody help me?

–Heres The Script

local GoalPosition = “0.265, 0,0.096, 0”
local OriginPosition = “0, 786,0, 631”

local TweenService = game:GetService(“TweenService”)
local Troll = game:GetService(“StarterGui”).Troll.ImageLabel

game.Players.LocalPlayer.Character:FindFirstChildWhichIsA(“Humanoid”).Died:Connect(function ()
print(“Check”)

local goal1 = {}
goal1.Position = UDim2.new(tonumber(GoalPosition))

local TweenInfo1 = TweenInfo.new(0.45)

local Tween1 = TweenService:Create(Troll, TweenInfo1, goal1)
Tween1:Play()
end)

–Its A Local Script

1 Like

Try:

local GoalPosition = 0.265, 0,0.096, 0
local OriginPosition = 0, 786,0, 631
-- Setup
local goal1 = {}
goal1.Position = UDim2.new(tonumber(GoalPosition))
local TweenInfo1 = TweenInfo.new(0.45)
local Tween1 = TweenService:Create(Troll, TweenInfo1, goal1)

local TweenService = game:GetService(“TweenService”)
local Troll = game.Players.LocalPlayer.PlayerGui:WaitForChild("Troll").ImageLabel

game.Players.LocalPlayer.Character:FindFirstChildWhichIsA(“Humanoid”).Died:Connect(function ()
print(“Check”)
Tween1:Play()
end)
1 Like

its because youre tweening the ui in startergui, youre supposed to tween the ui in playergui

local Troll = game.Players.LocalPlayer.PlayerGui.Troll.ImageLabel
4 Likes

sorry i forgot about some, the first tween works but theres a second tween.

– Here’s The Full Script

local GoalPosition = “0.265, 0,0.096, 0”
local OriginPosition = “0, 786,0, 631”

local LocalPlayer = game.Players.LocalPlayer
local TweenService = game:GetService(“TweenService”)
local Troll = LocalPlayer:WaitForChild(“PlayerGui”).Troll.ImageLabel

–tween1

local goal1 = {}
goal1.Position = UDim2.new(tonumber(GoalPosition))
local TweenInfo1 = TweenInfo.new(0.45)
local Tween1 = TweenService:Create(Troll, TweenInfo1, goal1)

–tween2

local goal2 = {}
goal2.Position = UDim2.new(tonumber(OriginPosition))
local TweenInfo2 = TweenInfo.new(0.45)
local Tween2 = TweenService:Create(Troll, TweenInfo2, goal2)

game.Players.LocalPlayer.Character:FindFirstChildWhichIsA(“Humanoid”).Died:Connect(function ()

Tween1:Play()
task.wait(1)
Tween2:Play()

end)

You can do Tween1.Completed:Wait() instead of task.wait() it should work.

1 Like

it still didnt work? do you have any other suggestions?

Turn off the “ResetOnSpawn” property inside of the ScreenGui

yeah i turned that off when i started

Maybe this?

	local LocalPlayer = game.Players.LocalPlayer
	local TweenService = game:GetService("TweenService")
	local Troll = LocalPlayer.PlayerGui.Troll.ImageLabel

	local goal1 = {}
	goal1.Position = UDim2.new(0.265, 0,0.096, 0)
	local TweenInfo1 = TweenInfo.new(0.45)
	local Tween1 = TweenService:Create(Troll, TweenInfo1, goal1)

	local goal2 = {}
	goal2.Position = UDim2.new(0, 786,0, 631)
	local TweenInfo2 = TweenInfo.new(0.45)
	local Tween2 = TweenService:Create(Troll, TweenInfo2, goal2)

	game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Humanoid").Died:Connect(function ()
		Tween1:Play()
		task.wait(1)
		Tween2:Play()
	end)
2 Likes

that worked, thanks for helping me out!

2 Likes

What was up with the UDim2.new(tonumber(string))

I think that was your issue, since tonumber will return nil if it fails to turn it into a number , that’s because i think it can’t contain " , " I think. It also can’t contain any other characters except numbers, or else it will return nil. (I think it can contain " . " since there can be integers like 1.69 and stuff, I think)

1 Like

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