local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local rewardEvent = ReplicatedStorage:WaitForChild("CoinRewardEvent")
local SOUND_ID = "rbxassetid://1210852193"
local function showRewardMessage(coins)
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "CoinRewardGui"
screenGui.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(0.3, 0, 0.1, 0) -- 30% width, 10% height
textLabel.Position = UDim2.new(0.35, 0, 0.4, 0) -- Centered horizontally
textLabel.BackgroundColor3 = Color3.fromRGB(85, 255, 127)
textLabel.TextColor3 = Color3.new(1, 1, 1)
textLabel.Font = Enum.Font.FredokaOne
textLabel.TextScaled = true
textLabel.Text = "You earned " .. coins .. " Coins because you've been playing for 10 minutes!"
textLabel.Parent = screenGui
textLabel:TweenPosition(UDim2.new(0,0,1,0), "InOut", "Quad",3.5)
local sound = Instance.new("Sound")
sound.SoundId = SOUND_ID
sound.Volume = 1
sound.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")
sound:Play()
task.wait(3)
for i = 1, 20 do
textLabel.TextTransparency = i * 0.05
task.wait(0.05)
end
screenGui:Destroy()
sound:Destroy()
end
rewardEvent.OnClientEvent:Connect(showRewardMessage)
I would like to add UI Corners to make the text look nicer, but I cannot seem to find a way to do it in any documentation, and then I’d like to have a smooth tween animation that makes the button pop up at the center top of the screen for 5 seconds and then go back up again but I cannot seem to make it work.
I’d like some help in doing those tasks.
Thanks in advance!
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local rewardEvent = ReplicatedStorage:WaitForChild("CoinRewardEvent")
local SOUND_ID = "rbxassetid://1210852193"
local function showRewardMessage(coins)
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "CoinRewardGui"
screenGui.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(0.3, 0, 0.1, 0) -- 30% width, 10% height
textLabel.Position = UDim2.new(0.353, 0, 0.014, 0) -- Centered horizontally, Changed X Position to the middle and left a small gap from the top of the screen
textLabel.BackgroundColor3 = Color3.fromRGB(85, 255, 127)
textLabel.TextColor3 = Color3.new(1, 1, 1)
textLabel.Font = Enum.Font.FredokaOne
textLabel.TextScaled = true
textLabel.Text = "You earned " .. coins .. " Coins because you've been playing for 10 minutes!"
textLabel.Parent = screenGui
local uiCorner = Instance.new("UICorner") -- We create a UI Corner Instance
uiCorner.Parent = textLabel
uiCorner.CornerRadius = UDim.new(0.1, 0) -- Set the properties (Scale, Offset fyi)
textLabel:TweenPosition(UDim2.new(0.353,0,1,0), "InOut", "Quad",3.5) -- Tween it (I changed the X position to the middle)
local sound = Instance.new("Sound")
sound.SoundId = SOUND_ID
sound.Volume = 1
sound.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")
sound:Play()
task.wait(3)
for i = 1, 20 do
textLabel.TextTransparency = i * 0.05
task.wait(0.05)
end
screenGui:Destroy()
sound:Destroy()
end
rewardEvent.OnClientEvent:Connect(showRewardMessage)
Let me know if there’s anything else! I also left comments just so you know what I changed
Hope this is what you are looking for! (P.S, mark as solution if that’s the case )
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local rewardEvent = ReplicatedStorage:WaitForChild("CoinRewardEvent")
local SOUND_ID = "rbxassetid://1210852193"
local function showRewardMessage(coins)
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "CoinRewardGui"
screenGui.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(0.3, 0, 0.1, 0) -- 30% width, 10% height
textLabel.Position = UDim2.new(0.353, 0, -0.5, 0) -- Centered horizontally, Changed X Position to the middle and made it so it's off the screen
textLabel.BackgroundColor3 = Color3.fromRGB(85, 255, 127)
textLabel.TextColor3 = Color3.new(1, 1, 1)
textLabel.Font = Enum.Font.FredokaOne
textLabel.TextScaled = true
textLabel.Text = "You earned " .. coins .. " Coins because you've been playing for 10 minutes!"
textLabel.Parent = screenGui
local uiCorner = Instance.new("UICorner") -- We create a UI Corner Instance
uiCorner.Parent = textLabel
uiCorner.CornerRadius = UDim.new(0.1, 0) -- Set the properties (Scale, Offset fyi)
local sound = Instance.new("Sound")
sound.SoundId = SOUND_ID
sound.Volume = 1
sound.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")
sound:Play()
textLabel:TweenPosition(UDim2.new(0.353,0,0.014,0), "InOut", "Quad",0.8) -- Tween it, the "pop in" tween
task.wait(5)
textLabel:TweenPosition(UDim2.new(0.353,0,-0.5,0), "InOut", "Quad",0.8) -- Tween it, the "pop out" tween
local textTween = TweenService:Create(textLabel, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.In)) -- Instead of your for loop, I replaced it with a tween =)
textTween:Play()
textTween.Completed:Wait()
screenGui:Destroy()
sound:Destroy()
end
rewardEvent.OnClientEvent:Connect(showRewardMessage)