My script makes a loading screen effect and it disables itself after the loading is done but for some reason EVEN WHEN ITS DISABLED?? this has never happened to me before so I don't know why this is happening but i tried running some prints to find which script was running the loading frame (i have 3 scripts running the loading frame) and then i checked for its parent to make sure and then i checked if it was disabled.. output said it was disabled.
The LocalScript is in a textbutton parented to a folder which is parented to a frame which is parented to a screengui which is parented to startergui (playergui)
local loadingFrame = script.Parent.Parent.Parent.Parent.LoadingFrame script.Parent.MouseButton1Click:connect(function() script.Parent.Parent.Parent:TweenPosition(UDim2.new(-0.5,0,0.053,0),"Out", "Quad") for i,v in pairs(script.Parent.Parent:GetChildren()) do if v.ClassName == "TextButton" then v.Visible = false end wait(.3) for i = 1,0,-.1 do print(script.Name) print(script.Parent) print(script.Disabled) loadingFrame.BackgroundTransparency = i wait(.1) end loadingFrame.ImageLabel.Visible = true local timer = 5 while timer ~= 0 do loadingFrame.ImageLabel:TweenSize(UDim2.new(0.061, 0,0.153, 0),"Out","Quad",.4) wait(.5) loadingFrame.ImageLabel:TweenSize(UDim2.new(0.065, 0,0.168, 0),"Out","Quad",.4) timer = timer - 1 print(timer) wait(.5) end for i = 0,1,.1 do loadingFrame.BackgroundTransparency = i loadingFrame.ImageLabel.Visible = false wait(.1) end wait(.2) for i,v in pairs(script.Parent.Parent.Parent:GetChildren()) do if v.ClassName == "TextButton" then v.Visible = true script.Parent.LocalScript.Disabled = false script.Disabled = true end end end end)
It's because you have 'while' loop and have to find a way to break it.
Try adding a break variable.
local break = false -- this will break the 'while' loop when set to 'true'
Then, add it a 'if' statement for the break variable.
while timer ~= 0 do if not break then -- if break is false, loop continues loadingFrame.ImageLabel:TweenSize(UDim2.new(0.061, 0,0.153, 0),"Out","Quad",.4) wait(.5) loadingFrame.ImageLabel:TweenSize(UDim2.new(0.065, 0,0.168, 0),"Out","Quad",.4) timer = timer - 1 print(timer) wait(.5) elseif break then -- if break is true, stops the 'while' loop print('broke loop') break end end
Now, set break to true before disabling the script.
for i,v in pairs(script.Parent.Parent.Parent:GetChildren()) do if v.ClassName == "TextButton" then v.Visible = true break = true -- sets break to true so the while loop stops script.Parent.LocalScript.Disabled = false script.Disabled = true end end
Hope this helped