Tweening headache

I’m making a tween script which utilizes tweens to show the player their position and reward received after completing an obby. Although the tween for “Top3Finish” does not seem to trigger, why is that?

local RS = game:GetService("ReplicatedStorage"):WaitForChild("Elevator"):WaitForChild("Win")

local TweenService = game:GetService("TweenService")

-- DoorPart

RS.OnClientEvent:Connect(function(position, reward)
	
	script.Win:Play()
	
	local TextLabel = Instance.new("TextLabel")

	--Properties:

	TextLabel.Parent = script.Parent.Parent.Parent
	TextLabel.Name = "CoinReward"
	TextLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
	TextLabel.BackgroundTransparency = 1.000
	TextLabel.BorderColor3 = Color3.fromRGB(0, 0, 0)
	TextLabel.BorderSizePixel = 0
	TextLabel.Position = UDim2.new(0.075, 0, 0.489, 0)
	TextLabel.Size = UDim2.new(0.113149211, 0, 0.0604938269, 0)
	TextLabel.ZIndex = -5
	TextLabel.Font = Enum.Font.SourceSansBold
	TextLabel.Text = reward
	TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
	TextLabel.TextScaled = true
	TextLabel.TextSize = 14.000
	TextLabel.TextWrapped = true
	
	--
	
	local Top3Finish = Instance.new("TextLabel")

	Top3Finish.Name = "Top3Finish"
	TextLabel.Parent = script.Parent.Parent.Parent
	Top3Finish.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
	Top3Finish.BackgroundTransparency = 1.000
	Top3Finish.BorderColor3 = Color3.fromRGB(0, 0, 0)
	Top3Finish.BorderSizePixel = 0
	Top3Finish.Position = UDim2.new(0.386808038, 0, 0.120987654, 0)
	Top3Finish.Size = UDim2.new(0.224959821, 0, 0.0851851851, 0)
	Top3Finish.ZIndex = -5
	Top3Finish.Font = Enum.Font.SourceSansBold
	if position<4 then
		if position == 1 then
			Top3Finish.Text = "1st place!"
		end
		if position == 2 then
			Top3Finish.Text = "2nd place"
		end
		if position == 3 then
			Top3Finish.Text = "3rd place!"
		end
	else
		Top3Finish.Text = position.."th place!"
	end
	
	Top3Finish.TextColor3 = Color3.fromRGB(255, 255, 255)
	Top3Finish.TextScaled = true
	Top3Finish.TextSize = 14.000
	Top3Finish.TextWrapped = true
	
	--
	
	local Pos1 = UDim2.new(0.075, 0, 0.487, 0)
	local Pos2 = UDim2.new(0.075, 0, 0.428, 0)

	local TweenInfo = TweenInfo.new(.25)

	local Tween1 = TweenService:Create(TextLabel, TweenInfo, {Position = Pos2})
	local Tween2 = TweenService:Create(TextLabel, TweenInfo, {Position = Pos1})
	
	--
	
	local Pos1Win = UDim2.new(0.374, 0, 0.028, 0)
	local Pos2Win = UDim2.new(0.374, 0, 0.121, 0)

	local Tween1Win = TweenService:Create(Top3Finish, TweenInfo, {Position = Pos2Win})
	local Tween2Win = TweenService:Create(Top3Finish, TweenInfo, {Position = Pos1Win})

	Tween1Win:Play() -- Does not trigger
	Tween1:Play() -- Does trigger
	wait(3)
	-- Tween2Win:Play()
	-- Tween2:Play()
	
	wait(.5)
	
	-- TextLabel:Destroy()
	-- Top3Finish:Destroy()
end)

The issue is that when your doing your TweenInfo You need to set the name of the variable to something other than ‘TweenInfo’ as that already exists so your script is currently thinking that you’ve got no information about your tween the best way to fix it would be doing this

	local Tweeninfo = TweenInfo.new(.25)

	local Tween1 = TweenService:Create(TextLabel, Tweeninfo, {Position = Pos2})
	local Tween2 = TweenService:Create(TextLabel, Tweeninfo, {Position = Pos1})

	--

	local Pos1Win = UDim2.new(0.374, 0, 0.028, 0)
	local Pos2Win = UDim2.new(0.374, 0, 0.121, 0)

	local Tween1Win = TweenService:Create(Top3Finish, Tweeninfo, {Position = Pos2Win})
	local Tween2Win = TweenService:Create(Top3Finish, Tweeninfo, {Position = Pos1Win})

Be careful with your capital letters!

2 Likes

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