Hey Ki_ngPhantom,
I've figured out the issue in your second script as to why your blur effect doesn't stop at 0. However, there are some enhancements you can definitely make with that script which can improve your script quiet a lot, I will go over those in this answer as well and it's my best advise that you take it.
#Issues
##Useless if statement and while loop, and Operator Problem
###Your first and foremost issue that I saw in your second script was the while loop. In-fact it crashed the game so I had to kill the script and make a new file. Anyways, get rid of that while loop, it's useless in your situation and you forgot to put a wait in there but, the while loop is not needed. The other issue that I found was in your repeat loop. First off, I don't even know why you're using a repeat loop. I'll go over enhancing that loop into a better one later but, for now let's go over why it didn't work quiet as well as you supposed it would. Ok so, your repeat loop checked if the Size is equal to 0 however, by the time it was checking if the size was equal to 0, the size had already changed because of how fast the code went. So, for this I'd advise using <= to operator to check for that. Below is the script assuming that everything else(like the tweening) works fine in your script. Also, I removed that useless if statement you had below the :MoveTo() method.
####Issues Fixed Example
local frame = script.Parent.Parent
local blur = game.Lighting:WaitForChild("Blur")
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
frame:TweenPosition(UDim2.new(-1,0,-0.052,0), "In", "Sine", 1.5)
wait(0.3)
repeat blur.Size = blur.Size - 0.1 wait(0.01) until blur.Size <= 0
blur.Enabled = false
player.Character:MoveTo(Vector3.new(-202, 6.1, 44))
wait(5)
end)
###If you replace your second script with the one above, everything should work just fine however, I'm gonna give you some enhancements to your code and I highly recommend you check this out because it's for both of your scripts.
#Enhancements
###I made exactly what you wanted to make and then compared your script to mine and that's how my enhancements were established so, most of these examples are done with my coding and they use well-updated and efficient methods.
##Script 1: Humanoid Died Event with CharacterAdded, :WaitForChild() and :GetService()
###Alright, so you have a while loop running through out the whole game. This can make your game lag and having a loop run at all times is just a terrible idea because it can increase latency in your game. I recommend using the CharacterAdded event to detect when the Character is added and then simply make a variable for the Humanoid and use it's Died event. :WaitForChild() method makes your game anti-StreamingEnabled and you are not making many requests for your game to get certain items rather, you wait for them so your game decreases in lag. :GetService() is good to use because in the future the names of the Services might change and you will not be able to just get them by doing game.Service, so it gives your script a nice foundation and good durability. Below is an enhancement example of this.
####Enhancement Example A
local players = game:GetService("Players")
local player = players.LocalPlayer;
local lighting = game:GetService("Lighting");
local blur = lighting:WaitForChild("Blur");
player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid");
hum.Died:Connect(function()
blur.Enabled = true
repeat blur.Size = blur.Size + 0.1 wait(0.01) until blur.Size == 24
end)
end)
##Script 1: For loop instead of repeat loop
###For your purposes, I would suggest using a for loop because I believe that not only will it decrease lag but, it will make your script better organized and it's very easy to make as well, at least for your purposes. Below is an enhancement example of this.
####Enhancement Example B
local players = game:GetService("Players")
local player = players.LocalPlayer;
local lighting = game:GetService("Lighting");
local blur = lighting:WaitForChild("Blur");
player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid");
hum.Died:Connect(function()
blur.Enabled = true;
for i = 0, 24, 0.1 do
wait(0.01);
blur.Size = i;
end
end)
end)
##Script 2: :WaitForChild() and :GetService()
###Well, I showed you how to do that above so all you have to do is implement that into this every time you declare a variable. But, I'll show you how to do it just in-case you get stuck. Below is an enhancement example of this.
####Enhancement Example C
local frame = script.Parent.Parent;
local lighting = game:GetService("Lighting")
local blur = lighting:WaitForChild("Blur")
local players = game:GetService("Players")
local player = players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
frame:TweenPosition(UDim2.new(-1,0,-0.052,0), "In", "Sine", 1.5)
wait(0.3)
repeat blur.Size = blur.Size - 0.1 wait(0.01) until blur.Size <= 0
blur.Enabled = false
player.Character:MoveTo(Vector3.new(-202, 6.1, 44))
wait(5)
end)
##Script 2: For loop instead of repeat loop.
###I talked about this above as well and from that script up there you should be able to do it here but, I'll provide you with an example just in-case you need it.
####Enhancement Example D
local frame = script.Parent.Parent;
local lighting = game:GetService("Lighting")
local blur = lighting:WaitForChild("Blur")
local players = game:GetService("Players")
local player = players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
frame:TweenPosition(UDim2.new(-1,0,-0.052,0), "In", "Sine", 1.5)
wait(0.3)
for i = 24, 0, -0.1 do
wait(0.01)
blur.Size = i;
end
blur.Enabled = false
player.Character:MoveTo(Vector3.new(-202, 6.1, 44))
wait(5)
end)
##Well, that should've covered it all and if it still doesn't work then please comment below.
~~ KingLoneCat
4 comments
I would have used the tween service :P
I didn't mess with any of his tweening because I don't have the environment he has in his game.
How long did it take to write this?
Like an hour.