Stop a "for = i" loop at the exact number

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.

1 Like

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.

Find The Cola’s (1).rbxl (47.2 KB)

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)
1 Like

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.