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