I’m trying to make a localscript which shows the player how much money they have just picked up from a coin collect, though I believe my tween is not working correctly.
The tween is supposed to make the popup slide up from behind another GUI object and slide back down behind it before being deleted again.
Here is the local script (showing only the info related to the tween):
-- Tween
local Pos1 = UDim2.new(0.075, 0, 0.489, 0) -- Where the tween starts and returns to
local Pos2 = UDim2.new(0.306, 0, -1, 0) -- Where the tween ends
local TweenInfo = TweenInfo.new(2)
local Tween1 = TweenService:Create(TextLabel, TweenInfo, {Position = Pos2})
Tween1:Play()
end)
What can I do to make this tween function correctly?
Here is the full localscript for more context
local RS = game:GetService("ReplicatedStorage"):WaitForChild("CoinCollect"):WaitForChild("CollectCoin")
local TweenService = game:GetService("TweenService")
-- DoorPart
RS.OnClientEvent:Connect(function(reward)
script.Win:Play()
local TextLabel = Instance.new("TextLabel")
--Properties:
TextLabel.Parent = game.StarterGui.Main
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 Pos1 = UDim2.new(0.075, 0, 0.489, 0) -- Where the tween starts and returns to
local Pos2 = UDim2.new(0.306, 0, -1, 0) -- Where the tween ends
local TweenInfo = TweenInfo.new(2)
local Tween1 = TweenService:Create(TextLabel, TweenInfo, {Position = Pos2})
Tween1:Play()
end)