Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local plr = owner
- local oldpos = CFrame.new()
- local rebirthing = false
- local started = false
- local connection = nil
- local whitelisted_parts = {'base','baseplate'}
- local pdata = {
- ws = 16,
- hh = 0,
- msa = 89,
- jp = 50,
- sit = false,
- platformstand = false,
- autorotate = true,
- usejumppower = true,
- autojump = true,
- --breakjoints = false
- --jump = false,
- }
- function update_pdata(...)
- local data = ...
- pdata = data
- end
- function wrap(f)
- return spawn(f)
- end
- function smart_add(p)
- wrap(function()
- for i,v in pairs(p:GetChildren()) do
- v.ChildAdded:Connect(function(obj)
- if obj:IsA('Script') or obj:IsA('LocalScript') or obj:IsA('BodyForce') or obj:IsA('BodyGyro') or obj:IsA('BodyAngularVelocity') or obj:IsA('BodyPosition') or obj:IsA('BodyMover') or obj:IsA('BodyVelocity') or obj:IsA('BodyThrust') then
- obj:Destroy()
- end
- end)
- end
- end)
- end
- function load_pdata(char,torso,hum)
- pcall(function()
- hum.WalkSpeed = pdata.ws or 16;
- hum.HipHeight = pdata.hh or 0;
- hum.MaxSlopeAngle = pdata.msa or 89;
- hum.JumpPower = pdata.jp or 50;
- hum.Sit = pdata.sit or false;
- hum.PlatformStand = pdata.platformstand or false;
- hum.AutoRotate = pdata.autorotate or true;
- hum.UseJumpPower = pdata.usejumppower or true;
- hum.AutoJumpEnabled = pdata.autojump or true;
- hum.BreakJointsOnDeath = false;
- hum:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false);
- hum:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false);
- hum.MaxHealth = 1/0
- hum.Health = 1/0
- torso.Velocity = Vector3.new()
- torso.CFrame = oldpos
- local ff = char:FindFirstChildOfClass("ForceField")
- if ff then
- ff:Destroy()
- end
- local ff = Instance.new("ForceField")
- ff.Visible = false
- ff.Parent = char
- smart_add(char)
- make_barrier(torso,char,workspace)
- end)
- end
- local bid = 0
- function make_barrier(root,char,p)
- wrap(function()
- bid += 1
- local cid = bid
- if connection then connection:Disconnect(); end;
- local barrier = Instance.new("Part")
- barrier.Name = 'barrier'
- barrier.Transparency = 1
- barrier.Size = Vector3.new(10,10,10)
- barrier.CanCollide = false
- barrier.Massless = true
- barrier.Locked = true
- barrier.Archivable = false
- barrier.Parent = p
- local weld = Instance.new("Weld")
- weld.Part0 = root
- weld.Part1 = barrier
- weld.Parent = barrier
- barrier.Touched:Connect(function(obj)
- local n = obj.Name:lower()
- local found = false
- for i,v in pairs(whitelisted_parts) do
- if n and v == n then
- found = true;
- end;
- end;
- if (char and obj:IsDescendantOf(char)) or (plr.Character and obj:IsDescendantOf(plr.Character)) or not obj:FindFirstChildOfClass('TouchInterest') then
- found = true
- end
- if not found then
- obj:Destroy()
- end
- end)
- local c
- c = workspace.DescendantAdded:Connect(function(obj)
- if cid ~= bid then
- c:Disconnect()
- return
- end
- if obj:IsA("Weld") then
- local p0 = obj.Part0
- local p1 = obj.Part1
- if p0 == barrier then
- if p1 ~= barrier then
- p1:Destroy()
- end
- end
- if p1 == barrier then
- if p0 ~= barrier then
- p0:Destroy()
- end
- end
- obj:Destroy()
- end
- end)
- barrier.ChildAdded:Connect(function(obj)
- task.wait()
- if obj:IsA("Weld") then
- local p0 = obj.Part0
- local p1 = obj.Part1
- if p0 ~= barrier then
- p0:Destroy()
- end
- if p1 ~= barrier then
- p1:Destroy()
- end
- obj:Destroy()
- end
- end)
- connection = p.ChildRemoved:Connect(function(obj)
- if obj == barrier then
- if obj then obj:Destroy(); end;
- make_barrier(root,char,p)
- end
- end)
- end)
- end
- function setup()
- local char = plr.Character
- local torso = char:FindFirstChild("HumanoidRootPart")
- local hum = char:FindFirstChildOfClass("Humanoid")
- local died = false
- local function alive()
- local alive = false
- if char and char.Parent and (char.Parent == workspace) and torso and torso.Parent and hum and hum.Parent and hum.Health > 0 then
- alive = true
- end
- return alive
- end
- local function rebirth()
- rebirthing = true
- plr:LoadCharacter()
- char = plr.Character
- torso = char:FindFirstChild("HumanoidRootPart")
- hum = char:FindFirstChildOfClass("Humanoid")
- load_pdata(char,torso,hum)
- rebirthing = false
- setup()
- end
- local BODY = {}
- wrap(function()
- for _, c in pairs(char:GetDescendants()) do
- if c:IsA("BasePart") and c.Name ~= "Handle" then
- if c.Name ~= "RootPart" and c.Name ~= "Torso" and c.Name ~= "Head" and c.Name ~= "RightArm" and c.Name ~= "LeftArm" and c.Name ~= "RightLeg" and c.Name ~= "LeftLeg" then
- c.CustomPhysicalProperties = PhysicalProperties.new(0, 0, 0, 0, 0)
- end
- table.insert(BODY,{c,c.Parent,c.Material,c.Color,c.Transparency,c.Size,c.Name})
- elseif c:IsA("JointInstance") then
- table.insert(BODY,{c,c.Parent,nil,nil,nil,nil,nil})
- end
- end
- end)
- local function refit()
- --char.Parent = workspace
- for e = 1, #BODY do
- wrap(function()
- if BODY[e] ~= nil then
- local STUFF = BODY[e]
- local PART = STUFF[1]
- local PARENT = STUFF[2]
- local MATERIAL = STUFF[3]
- local COLOR = STUFF[4]
- local TRANSPARENCY = STUFF[5]
- --local SIZE = STUFF[6]
- local NAME = STUFF[7]
- if PART.ClassName == "Part" and PART.Name ~= "RootPart" then
- PART.Material = MATERIAL
- PART.Transparency = TRANSPARENCY
- PART.Name = NAME
- end
- if hum and PART and PART.Parent ~= PARENT then
- wrap(function()
- hum:Destroy()
- PART.Parent = PARENT
- hum = Instance.new("Humanoid")
- hum.Parent = char
- end)
- end
- end
- end)
- end
- end
- --wrap(function()
- while not died do
- if not alive() then
- died = true
- end
- if not alive() and not rebirthing then
- rebirth()
- end
- if alive() and not rebirthing and not died then
- refit()
- local tdata = {
- --ws = hum.WalkSpeed,
- --hh = hum.HipHeight,
- --msa = hum.MaxSlopeAngle,
- --jp = hum.JumpPower,
- sit = hum.Sit,
- --platformstand = hum.PlatformStand,
- --autorotate = hum.AutoRotate,
- --usejumppower = hum.UseJumpPower,
- --autojump = hum.AutoJumpEnabled,
- }
- update_pdata(tdata)
- if char then
- plr.Character = char
- end
- hum.MaxHealth = 1/0; hum.Health = 1/0;
- oldpos = torso.CFrame
- end
- if not started then
- started = true
- plr:LoadCharacter()
- end
- task.wait()
- end
- --end)
- end
- setup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement