local gui = game.StarterGui.SodaDiscoveredGUI.Frame.SodaName
ProximityPrompt.Triggered:connect(function(Player)
for i = 0, 1, 0.01 do
gui.TextTransparency -= i
gui.TextStrokeTransparency -= i
task.wait(0.1)
if gui.TextStrokeTransparency == 0 and gui.TextTransparency == 0 then
break
end
end
end)
Short and simple. I need this to make it so the GUI.TextTransparency and GUI.TextStrokeTransparency stop at exactly 0. They just keep going until like 50.
local gui = game.StarterGui.SodaDiscoveredGUI.Frame.SodaName
ProximityPrompt.Triggered:connect(function(Player)
for i = 0, 1, 0.01 do
if i == 0 then
break
end
gui.TextTransparency -= i
gui.TextStrokeTransparency -= i
task.wait(0.1)
if gui.TextStrokeTransparency == 0 and gui.TextTransparency == 0 then
break
end
end
end)
This is because you’re subtracting i every iteration. On iteration 1, gui.TextTransparency is reduced by 0.01 which equals 0.99. On iteration 2, gui.TextTransparency is reduced by 0.02, which equals 0.97, and so on. It isn’t decreasing at a linear rate.
To fix that, replace -= i with = 1 - i.
gui.TextTransparency = 1 - i
gui.TextStrokeTransparency = 1 - i
Also, if you’re looking to smoothly transition UI, I suggest looking into TweenService.
local ts = game:GetService(“TweenService”)
local one = ts:Create(gui,TweenInfo.new(2,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out,0,false,0),{TextStrokeTransparency = 0, TextTransparency = 0)
one:Play()
So, this actually worked, but oddly enough, the text doesn’t appear. It says the transparency is 0, but it simply isn’t there.
local ProximityPrompt = script.Parent
local gui = game.StarterGui.SodaDiscoveredGUI.Frame.SodaName
local ts = game:GetService("TweenService")
local one = ts:Create(gui,TweenInfo.new(2,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out,0,false,0),{TextTransparency = 0})
ProximityPrompt.Triggered:connect(function(Player)
print("Soda Collected")
one:Play()
end)
-- Services
local ps = game:GetService("Players")
local ts = game:GetService("TweenService")
-- Local Variables
local pp = script.Parent
-- Script
pp.Triggered:connect(function(Player)
local pgui = Player:WaitForChild("PlayerGui")
local gui = pgui:WaitForChild("SodaDiscoveredGUI")
local guiFrame1 = gui:WaitForChild("Frame")
local guiSodaName = gui:WaitForChild("SodaName")
local one = ts:Create(guiSodaName,TweenInfo.new(2,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out,0,false,0),{TextTransparency = 0})
one:Play()
repeat wait() until one.PlaybackState == Enum.PlaybackState.Completed
script.Parent:Destroy()
end)
In my opinion, using TweenService for something like this is a bit pointless; now you are achieving pretty much the same desired result but with more created instances and complexity.
I’m simply trying to find a way to make it so when you interact with a ProximityPrompt, it slowly adds text at the bottom of the screen for a short time, then the text fades away. This is being done in such a way where the script will be in every item. (There’s a lot of them).
You are overcomplicating your code. The break statement is unnecessary, and as with most times you use break to exit a loop, there is probably a better way.
This is how I’d do it:
local gui = game.StarterGui.SodaDiscoveredGUI.Frame.SodaName
ProximityPrompt.Triggered:connect(function(Player)
for i = 0, 1, 0.01 do
gui.TextTransparency = 1 - i
gui.TextStrokeTransparency = 1 - i
task.wait(0.1)
end
end)