Do you have Visible
set to true
in the TextObject?
Yep. Itâs all correct. Itâs in the StarterGUI, and the script you provided DOES make it go to 0 transparency, but it DOESNâT actually make the text appear.
Edit: Even setting the transparency in the game doesnât work. Iâm gonna try to remake the GUI, incase I messed something up
Is there actually text in the Textbox?
EDIT: Enable TextScaled
and see if that fixes it. If the text is too big, and TextWrapped
is enabled, the text will move to a new line and not be visible.
Thatâd be it. I donât have it to TextScaled. Question though, is it possible to have it work without TextScaled?
Yes, you could just change the TextSize
to something lower, which fits.
You could also create a script which finds an appropraite height using the workspace.CurrentCamera.viewportSize.Y
. Something like
textSize = viewportHeight / textScale
Where viewportHeight
is what I showed aboved, and textScaled
is an arbitrary number.
Okay, sorry to reply again, but this didnât seem to work. Should I send you the place file?
Sure, I could more easily troubleshoot it that way.
Okay, I immediately see your problem. You are editing the GUI in StarterGui
instead of in the Playerâs PlayerGui
. Hereâs a corrected script:
local ProximityPrompt = script.Parent
ProximityPrompt.Triggered:connect(function(Player)
local gui = Player:WaitForChild("PlayerGui"):WaitForChild("SodaDiscoveredGUI"):WaitForChild("Frame"):WaitForChild("SodaName")
for i = 0, 1, 0.01 do
gui.TextTransparency = 1 - i
task.wait(0.1)
end
end)
Last question, is the client sided or server sided?
Itâs server sided still. It could be client sided if you want, but thatâd be more complicated.
Well, basically, this is a finding game, so when a user finds a soda can, it tells them. I need that to only appear on the screen of the player who found it.
Yes, it will only appear on the screen of the player who triggered the proximity prompt.
Alright, thanks so much! Sorry for the bother
local ProximityPrompt = script.Parent
ProximityPrompt.Triggered:Connect(function(Player)
local soda = Player.PlayerGui.SodaDiscoveredGUI.Frame.SodaName
for i = 1, 0, -0.01 do
soda.TextTransparency = i
task.wait(0.1)
end
end)
You donât need any of those â:WaitForChild()â calls, by the time the prompt has been triggered all of those GuiObjects will have been instanced, avoid using the deprecated connection method â:connect()â, and opt to use the up to date version â:Connect()â instead. Finally, numeric for loops can decrease in value from the control variable (as in the above where the loop starts at 1 and decrements by a step of 0.01 until 0 is reached).
While the :WaitForChild()
calls may be unecessary, they are not useless. There could be an instance, on a slow machine, or in some other edge-case where they would not have loaded in. WaitForChild
will return the child immediately if it exist, and only wait in the event that the child is not yet in existence, so using it doesnât yield the program or cause lag. While it may result in a slightly longer run times (probably under 1ms extra), itâs worth it because of the edge-cases and bugs that it can help to avoid.