[SOLVED] When i do: "while true do" my studio almost crashes, everytime: Lag amount: 10 seconds

no they are not, clearly you don’t know how that works as the first example is actually slower and less efficient.
You shouldn’t be using wait() without a number either. Actually you shouldn’t be using wait(number) at all due to it being deprecated. Instead use task.wait(number)

1 Like

Why would you want to use a loop for something this minimal though? Things would be smoother and more performant by utilization of the TweenService and creating a Tween for the BackgroundTransparency and TextTransparency properties to be tweened to a much more desirable result.

1 Like

i never said that a loop should be used for solving this issue,
i was just correcting someone else.

1 Like

Just do while wait() do instead

1 Like

I did while task.wait(0.1) do instead.

But it still lagged so badly.

1 Like

even after I told you that it was incorrect and you shouldn’t be telling people that?

smthing like this maybe fix?

script.Parent.Title.TextSize = 80
wait(2)
while true do
	task.wait(0.1)
	script.Parent.Title.TextTransparency = 0.99 - script.Parent.Title.TextTransparency - 0.01
	repeat
		task.wait(0.1)
		script.Parent.Title.TextTransparency = 0 - 0.01 
	until 
	script.Parent.Title.TextTransparency == 0
end
1 Like

It helped me. But i don’t need to make the thing going to be instantly visible.

I’m just sorry if i don’t mark it as a solution :slightly_frowning_face:

Or it could be.

script.Parent.Title.TextSize = 80
wait(2)
while true do
	task.wait(0.5)
	script.Parent.Title.TextTransparency = 0.99 - script.Parent.Title.TextTransparency - 0.01
	repeat
		task.wait(0.5)
		script.Parent.Title.TextTransparency = 0 - 0.01 
	until 
	script.Parent.Title.TextTransparency == 0
end

?

Firstly apologies if this is clustered as I’m writing this out while on mobile,

Secondly I would suggest marking @LuigiLament’s earlier solution as a solution to your problem since it fixes the entire issue that this thread is discussing.

Thirdly l’ve attached an example for a Tween which is more performant when compared to using a loop to change a property. You could do this all in fewer lines, however, I’ve tried to add an explanation of what all is occurring in the below segment.

-- Services
local TweenService = game:GetService(‘TweenService’)

-- Variables
local buttonObj = pathToObj -- Path to the object which is having it’s properties tweened.

--[[

• Time: How long do you want the Tween to take to complete?

• EasingStyle: The documentation for Tweens represent this and the EasingDirection properties better than I can.

• EasingDirection: Refer above.

]]--
local buttonInfo = TweenInfo.new(time, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)

--[[

• First Parameter: Instance being tweened.

• Second Parameter: Our TweenInfo created above.

• Third Parameter: Dictionary w/ properties to be tweened.

]]--
local buttonTween = TweenService:Create(buttonObj, buttonInfo, {BackgroundTransparency = 1, TextTransparency = 1}) 

-- To play the Tween, run :Play()
buttonTween:Play()
  • Edit: Updated code segment to have singular double dashes (–) instead of iOS’s weird default double hyphen (—).

No i want to do the task.wait(0.1) BUT also make the text slightly visible by the time and not.

100% Invisible then 0% Invisible.

It caused me 34 errors and 19 warnings of all your script.

Try and remove the comments, iOS forces the double dashes to merge which is likely the cause of such.

Sorry i removed the script already…

script.Parent.Title.TextSize = 80

wait(2)

local time = 5 --the Time of tweenening

script.Parent.Title.TextTransparency = 0.99 - script.Parent.Title.TextTransparency - 0.01

game:GetService("TweenService"):Create(script.Parent.Title,TweenInfo.new(time),{TextTransparency = 0}):Play()
1 Like

It directly spawns it instead of waiting.

TO END THIS DUMB THREAD ONCE AND FOR ALL
There is literally no possible way this doesn’t work, and this is how you should’ve done it from the start.
replace your script with this, and please mark it as the solution if it works.

local TweenService = game:GetService("TweenService")

local t = 1.5 --the amount of time it takes for the tween to finish

script.Parent.Title.TextSize = 80
local g = { TextTransparency = 0 } --end goal of tween.
local tweeninfo = TweenInfo.new(t, Enum.EasingStyle.Linear, Enum.EasingDirection.Out) -- information for the tween
task.wait(1.5)
TweenService:Create(script.Parent.Title, tweeninfo, g):Play() --sets the instance to tween, sets the tweeninfo from above, and tells what property of title to tween, and then proceeds to play the tween.
1 Like

Do this

while true do
	task.wait()
	script.Parent.Title.TextTransparency = 0.99 - script.Parent.Title.TextTransparency - 0.01
	repeat 
	script.Parent.Title.TextTransparency = 0.99 - 0.01 
	task.wait() 
	until script.Parent.Title.TextTransparency == 0
end
1 Like

Unfortuanely, the script from @LuigiLament and @hakobmher works.

Not yours sorry.

1 Like

Thanks for the help.

I could just say it earlier.

I’m so dumb man, i could just simply say it.

Well, thanks.