ADVERTISEMENTREMOVE ADS
Phase | Universal + Solara support
48,653 views
Universal script•
1 year ago

Script Preview
ADVERTISEMENTREMOVE ADS
58 Lines • 2.03 KiB
Verified
local PhaseEnabled = true -- will it be enabled or not (true or false)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local LocalPlayer = Players.LocalPlayer
local CachedParts = {}
local RunLoops = {StepTable = {}}
function RunLoops:BindToStepped(name, func)
if RunLoops.StepTable[name] == nil then
RunLoops.StepTable[name] = RunService.Stepped:Connect(func)
end
end
function RunLoops:UnbindFromStepped(name)
if RunLoops.StepTable[name] then
RunLoops.StepTable[name]:Disconnect()
RunLoops.StepTable[name] = nil
end
end
local function IsAlive(Player, headCheck)
Player = Player or LocalPlayer
if Player and Player.Character and Player.Character:FindFirstChildOfClass("Humanoid") and Player.Character:FindFirstChild("HumanoidRootPart") and (not headCheck or Player.Character:FindFirstChild("Head")) then
return true
else
return false
end
end
if getgenv then
getgenv().Phase = {Enabled = PhaseEnabled}
else
_G.Phase = {Enabled = PhaseEnabled}
end
while IsAlive() do
if Phase.Enabled then -- no need for 'getgenv().Phase.Enabled' or '_G.Phase.Enabled' since you just can do 'Phase.Enabled', it will make your code look better, more readable and just cool
if not RunLoops.StepTable.Phase or RunLoops.StepTable.Phase == nil then
RunLoops:BindToStepped("Phase", function()
for _, v in pairs(LocalPlayer.Character:GetChildren()) do
if v:IsA("BasePart") and v.CanCollide then
CachedParts[v] = true
v.CanCollide = false
end
end
end)
end
else
for part in pairs(CachedParts) do
if part:IsA("BasePart") then
part.CanCollide = true
end
end
CachedParts = {}
RunLoops:UnbindFromStepped("Phase")
end
wait(0.1) -- delay to prevent high cpu usage and fps drop
end
ADVERTISEMENTREMOVE ADS
ADVERTISEMENTREMOVE ADS






Comments