Unable to stop phasing

Hello. Im making a speedster game where im creating a phase script. But for some reason when i try to stop phasing it just won’t work.

Help is very appreciated

Here is the script:

local player = game.Players.LocalPlayer
local char = script.Parent
local RS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local vibrating = nil

local blur = game.Lighting.Phasing

local debounce = false
UIS.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E then
		if not debounce then
			if vibrating == nil then
				vibrating = RS.RenderStepped:Connect(function()
					char.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(.250*math.sin(150*tick()), 0,0) --angle*math.sin(velocity*tick())
				end)
			debounce = true
			
			blur.Enabled = true
			else
				vibrating:Disconnect()
				vibrating = nil
				blur.Enabled = true

				debounce = false
			end
		end
	end  
end)

Thank you!

1 Like

You set it to true, and there’s nothing else that would make it back to false.

So this if condition is the reason why it’s not stopping.

1 Like

imma test this out later. Thank you

i fixed it by removing the if vibrating == nil then

local player = game.Players.LocalPlayer
local char = script.Parent
local RS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local vibrating = nil

local blur = game.Lighting.Phasing

local debounce = false
UIS.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E then
		if not debounce then
				vibrating = RS.RenderStepped:Connect(function()
				char.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(.250*math.sin(150*tick()), 0,0) --angle*math.sin(velocity*tick())
			end)
				
			debounce = true
			
			blur.Enabled = true
			else
				vibrating:Disconnect()
				vibrating = nil
				blur.Enabled = true

				debounce = false
			end
		end 
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.