Quick actions

cmd+k|ctrl+k

Navigation

Languages

LarryScript

Snippet info

Language

Lua

Visibility

public

Author

zen

Created

2024-08-25T22:24:35.531553Z

Updated

2024-08-31T21:33:09.972478Z

local ScriptENV do -- Basically EZConvert, but better :)
	--Be warned! Scripts may or may not have a noticable performance issue depending on the senario (unoptimized expensive loops etc)

	local Players = game:GetService("Players")
	local RunService = game:GetService("RunService")

	local _ENV = getfenv()

	local Player = _ENV.owner or Players:GetPlayerFromCharacter(script.Parent) or (script.Parent.Parent:IsA("Player") and script.Parent.Parent)

	if not Player then
		error("Cannot run script : must be ran in a sandbox, inside a character, or inside playergui/backpack")
	end

	local Remote = Player:FindFirstChild("SyncInput")

	if not Remote then
		Remote = Instance.new("RemoteEvent")
		Remote.Name = "SyncInput"
		Remote.Parent = Player
	end

	local Signal = (function() -- GoodSignal module by stravant
		local freeRunnerThread = nil
		local function acquireRunnerThreadAndCallEventHandler(fn, ...)
			local acquiredRunnerThread = freeRunnerThread
			freeRunnerThread = nil
			fn(...)
			freeRunnerThread = acquiredRunnerThread
		end
		local function runEventHandlerInFreeThread()
			while true do
				acquireRunnerThreadAndCallEventHandler(coroutine.yield())
			end
		end
		local Connection = {}
		Connection.__index = Connection
		function Connection.new(signal, fn)
			return setmetatable({
				_connected = true,
				_signal = signal,
				_fn = fn,
				_next = false,
			}, Connection)
		end
		function Connection:Disconnect()
			self._connected = false
			if self._signal._handlerListHead == self then
				self._signal._handlerListHead = self._next
			else
				local prev = self._signal._handlerListHead
				while prev and prev._next ~= self do
					prev = prev._next
				end
				if prev then
					prev._next = self._next
				end
			end
		end
		Connection.disconnect = Connection.Disconnect
		setmetatable(Connection, {
			__index = function(tb, key)
				--error(("Attempt to get Connection::%s (not a valid member)"):format(tostring(key)), 2)
			end,
			__newindex = function(tb, key, value)
				--error(("Attempt to set Connection::%s (not a valid member)"):format(tostring(key)), 2)
			end
		})
		local Signal = {}
		Signal.__index = Signal
		function Signal.new()
			return setmetatable({
				_handlerListHead = false,
			}, Signal)
		end
		function Signal:Connect(fn)
			local connection = Connection.new(self, fn)
			if self._handlerListHead then
				connection._next = self._handlerListHead
				self._handlerListHead = connection
			else
				self._handlerListHead = connection
			end
			return connection
		end
		function Signal:DisconnectAll()
			self._handlerListHead = false
		end
		function Signal:Fire(...)
			local item = self._handlerListHead
			while item do
				if item._connected then
					if not freeRunnerThread then
						freeRunnerThread = coroutine.create(runEventHandlerInFreeThread)
						-- Get the freeRunnerThread to the first yield
						coroutine.resume(freeRunnerThread)
					end
					task.spawn(freeRunnerThread, item._fn, ...)
				end
				item = item._next
			end
		end
		function Signal:Wait()
			local waitingCoroutine = coroutine.running()
			local cn;
			cn = self:Connect(function(...)
				cn:Disconnect()
				task.spawn(waitingCoroutine, ...)
			end)
			return coroutine.yield()
		end
		function Signal:Once(fn)
			local cn;
			cn = self:Connect(function(...)
				if cn._connected then
					cn:Disconnect()
				end
				fn(...)
			end)
			return cn
		end

		Signal.wait = Signal.Wait 
		Signal.fire = Signal.Fire 
		Signal.connect = Signal.Connect 

		-- Signal.once doesn't exist in luau, so we don't add it here.

		setmetatable(Signal, {
			__index = function(tb, key)
				-- have to bypass it this way or the script shits itself
				--error(("Attempt to get Signal::%s (not a valid member)"):format(tostring(key)), 2)
			end,
			__newindex = function(tb, key, value)
				-- have to bypass it this way or the script shits itself
				--error(("Attempt to set Signal::%s (not a valid member)"):format(tostring(key)), 2)
			end
		})
		return Signal
	end)()

	local NLS = _ENV.NLS

	if NLS then -- If NLS doesn't exist, a local script should be parented to this script (with the same code).
		NLS([[local Player = game:GetService("Players").LocalPlayer
	local Remote = Player:WaitForChild("SyncInput")
	
	local UserInputService = game:GetService("UserInputService")
	
	if not Remote then
		error("Cannot run script: Unable to find remote - Client failed to launch")
	end
	
	local UpdateInterval = 1 / 30
	
	local Mouse = Player:GetMouse()
	
	local InputObjectProperties = {
		"Position",
		"KeyCode",
		"UserInputType",
		"UserInputState",
		"Delta",
	}

	local MouseProperties = {
		"Hit",
		"Icon",
		"Origin",
		"Target",
		"TargetFilter",
		"TargetSurface",
		"UnitRay",
		"ViewSizeX",
		"ViewSizeY",
		"X",
		"Y",
		"hit",
		"target",
	}
	
	UserInputService.InputBegan:Connect(function(Input, GP)
		local Package = {}
		
		for i = 1, #InputObjectProperties do
			local Name = InputObjectProperties[i]
			Package[Name] = Input[Name]
		end
		
		Remote:FireServer(1, Package, GP)
	end)
	
	UserInputService.InputChanged:Connect(function(Input, GP)
		local Package = {}
		
		for i = 1, #InputObjectProperties do
			local Name = InputObjectProperties[i]
			Package[Name] = Input[Name]
		end
		
		Remote:FireServer(2, Package, GP)
	end)
	
	UserInputService.InputEnded:Connect(function(Input, GP)
		local Package = {}
		
		for i = 1, #InputObjectProperties do
			local Name = InputObjectProperties[i]
			Package[Name] = Input[Name]
		end
		
		Remote:FireServer(0, Package, GP)
	end)
	
	local ReplicateList = {}
	
	Remote.OnClientEvent:Connect(function(Type, Package)
		if Type == 0 then
			local Object = Package[1]
			local Properties = Package[2]
			
			ReplicateList[Object] = Properties
			
			for i = 1, #Properties do
				local Name = Properties[i]
				Object:GetPropertyChangedSignal(Name):Connect(function()
					if table.find(ReplicateList, Name) then return end
				
					table.insert(ReplicateList[Object], Object[Name])
				end)
			end
		end
	end)
	
	function Update()
		local MousePackage = {}
		
		for i = 1, #MouseProperties do
			local Name = MouseProperties[i]
			MousePackage[Name] = Mouse[Name]
		end
		
		Remote:FireServer(3, {
			Mouse = MousePackage,
			Replicate = ReplicateList
		})
	end
	
	Update()
	
	while true do
		task.wait(UpdateInterval)
		
		Update()
	end]], Player.PlayerGui)
	end

	task.wait(0.5)

	local Mouse = {}
	local UserInputService = {}

	Mouse.KeyDown = Signal.new()
	Mouse.KeyUp = Signal.new()
	Mouse.Button1Down = Signal.new()
	Mouse.Button1Up = Signal.new()
	Mouse.Button2Down = Signal.new()
	Mouse.Button2Up = Signal.new()

	--TODO: Implement these
	Mouse.Move = Signal.new()
	Mouse.Idle = Signal.new()

	-- TODO: More UserInputService properties.
	UserInputService.InputBegan = Signal.new()
	UserInputService.InputEnded = Signal.new()
	UserInputService.InputChanged = Signal.new()

	UserInputService.InputBegan:Connect(function(Input, GP)
		if not GP then
			if Input.KeyCode ~= Enum.KeyCode.Unknown then
				Mouse.KeyDown:Fire(utf8.char(Input.KeyCode.Value))
			end
			if Input.UserInputType == Enum.UserInputType.MouseButton1 then
				Mouse.Button1Down:Fire()
			end
			if Input.UserInputType == Enum.UserInputType.MouseButton2 then
				Mouse.Button2Down:Fire()
			end
		end
	end)

	UserInputService.InputEnded:Connect(function(Input, GP)
		if not GP then
			if Input.KeyCode ~= Enum.KeyCode.Unknown then
				Mouse.KeyUp:Fire(utf8.char(Input.KeyCode.Value))
			end
			if Input.UserInputType == Enum.UserInputType.MouseButton1 then
				Mouse.Button1Up:Fire()
			end
			if Input.UserInputType == Enum.UserInputType.MouseButton2 then
				Mouse.Button2Up:Fire()
			end
		end
	end)

	local MouseProperties = {}

	for Name, Connection in Mouse do 
		Mouse[Name:sub(1,1)..Name:sub(2)] = Connection
	end

	for Name, Connection in UserInputService do 
		Mouse[Name:sub(1,1)..Name:sub(2)] = Connection
	end

	local InputTypes = {
		[0] = "InputEnded",
		[1] = "InputBegan",
		[2] = "InputChanged",
		-- Number 3 is specially handled
	}

	local ReplicatedProperties = {}

	Remote.OnServerEvent:Connect(function(Sender, Type, Package, ...)
		local UISType = InputTypes[Type]
		if UISType then
			UserInputService[UISType]:Fire(Package, ...)
		end

		if Type == 3 then -- Mouse and replication stuff
			MouseProperties = Package.Mouse
			ReplicatedProperties = Package.Replicate
		end
	end)

	function Unsandbox(Value)
		if Value and typeof(Value) == "table" then
			local Real = Value._Real
			if Real then
				return Real
			end
		end
	end

	function GetReplicated(Object, Property)
		if not ReplicatedProperties[Object] then
			local Replicate = {
				[Property] = 0
			}
			ReplicatedProperties[Object] = Replicate
			Remote:FireClient(Player, 0, {Object, Replicate})
		end

		local ReplicatedProperty = ReplicatedProperties[Object]

		if not ReplicatedProperty[Property] then
			ReplicatedProperties[Object][Property] = Object[Property]
		end

		return ReplicatedProperty[Property]
	end

	function Sandbox(Object, Custom)
		if Object == nil then
			return
		end
		if Unsandbox(Object) then
			return Object
		end
		return setmetatable({}, {
			__index = function(self, Property)
				if Property == "_Real" then
					return Object
				end

				local CustomValue = (Custom and Custom[Property])
				if CustomValue then
					return CustomValue
				end

				local Value = Object[Property]

				local Unsandboxed = Unsandbox(Value)

				if Property == "PlaybackLoudness" or Property == "playbackLoudness" then					
					return GetReplicated(Object, "PlaybackLoudness")
				end

				if Value and typeof(Value) == "function" then
					return function(_, ...)
						local UnsandboxedArgs = {...}
						for i = 1, #UnsandboxedArgs do 
							UnsandboxedArgs[i] = Unsandbox(UnsandboxedArgs[i]) or UnsandboxedArgs[i]
						end
						local Result = Value(Object, table.unpack(UnsandboxedArgs))
						if Result then
							if typeof(Result) == "Instance" then
								Result = Sandbox(Result)
							end
							if typeof(Result) == "table" then
								for Index, Object in Result do 
									if typeof(Object) == "Instance" then
										Result[Index] = Sandbox(Object)
									end
								end
							end
						end
						return Result
					end
				end
				if Value and typeof(Value) == "Instance" then
					Value = Sandbox(Value)
				end

				return Value
			end,
			__newindex = function(self, Property, Value)
				Object[Property] = Unsandbox(Value) or Value
			end,
			__metatable = "The metatable is locked",
			__type = "Instance",
			__tostring = function()
				return Object.Name
			end,
		})
	end

	local NewENV = {}
	NewENV.typeof = function(Object)
		local Unsandboxed = Unsandbox(Object)
		return (Unsandboxed and typeof(Unsandboxed) or typeof(Object))
	end

	NewENV.type = function(Object)
		local Unsandboxed = Unsandbox(Object)
		return (Unsandboxed and type(Unsandboxed) or type(Object))
	end

	local FakeMouse = setmetatable({}, {
		__index = function(self, Property)
			return Mouse[Property] or MouseProperties[Property]
		end,
		__newindex = function(self, Property, Value)
			error("Cant set property of \"Mouse\"", 2)
		end,
		__metatable = "The metatable is locked",
		__type = "Instance",
		__tostring = function()
			return "Mouse"
		end,
	})

	function GetMouse()
		return FakeMouse
	end

	local FakePlayer = Sandbox(Player, {
		GetMouse = GetMouse,
		getMouse = GetMouse
	})

	local FakePlayers = Sandbox(Players, {
		LocalPlayer = FakePlayer,
		localPlayer = FakePlayer
	})

	local Services = {
		Players = FakePlayers,
		players = FakePlayers,
		UserInputService = UserInputService,
		userInputService = UserInputService,
	}

	function GetService(_, Name)
		return Sandbox(Services[Name] or game:GetService(Name))
	end

	NewENV.script = Sandbox(script, {
		Parent = Player.Character,
		parent = Player.Character
	})

	NewENV.game = Sandbox(game, {
		table.unpack(Services),
		GetService = GetService,
		getService = GetService,
		service = GetService,
	})

	NewENV.Instance = {
		new = function(Class, Parent)
			return Sandbox(Instance.new(Class, Unsandbox(Parent) or Parent))
		end,
	}

	NewENV.owner = Player	
	NewENV.mouse = FakeMouse

	NewENV.LoadLibrary = function(Library)
		if Library == "RbxUtility" then
			return {
				Create = function(Class)
					local Object = NewENV.Instance.new(Class)
					return function(Properties)
						for Name, Value in Properties do
							Object[Name] = Value
						end
						return Object
					end
				end
			}
		end
	end

	ScriptENV = setmetatable({}, {
		__index = function(self, Index)
			return NewENV[Index] or _ENV[Index]
		end,
		__newindex = function(self, Index, Value)
			rawset(ScriptENV, Index, Value)
		end,
		__metatable = "The metatable is locked"
	})
end

setfenv(1, ScriptENV)

local create = {
	sound = function(id: number,volume: number,parent)
		local sound = Instance.new("Sound")
		sound.Parent = parent
		sound.SoundId = "rbxassetid://"..id
		sound.Volume = volume
		sound:Play()

		sound.Ended:Connect(function()
			sound:Destroy()
		end)
	end,

	meshPart = function(meshId: string): MeshPart
		return game:GetService("InsertService"):CreateMeshPartAsync(meshId,Enum.CollisionFidelity.Hull,Enum.RenderFidelity.Automatic)
	end,

	weld = function(parent,part0: BasePart,part1: BasePart,c0: CFrame,c1: CFrame,between: boolean): Weld
		assert(part0,"Part0 required.")
		assert(part1,"Part1 required.")
		local w = Instance.new("Weld")
		w.Parent = parent or nil
		w.Part0 = part0
		w.Part1 = part1

		if not between then
			w.C0 = c0
			w.C1 = c1
		else
			w.C1 = part1.CFrame:Inverse() * part0.CFrame
		end
		
		return w
	end,

	part = function(size,shape,material,transparency,reflectance,color,name,anchored,parent): Part
		local p = Instance.new("Part")
		p.Size = size or Vector3.zero
		p.Shape = shape or Enum.PartType.Block
		p.Material = material or Enum.Material.Plastic
		p.Transparency = transparency or 0
		p.Reflectance = reflectance or 0
		p.Color = color or Color3.fromRGB(255,255,255)
		p.Name = name or "Part"
		p.Anchored = anchored or false
		p.Parent = parent or nil

		return p
	end,
	
	decal = function(parent,texture: string,face: Enum.NormalId): Decal
		local d = Instance.new("Decal")
		d.Texture = texture
		d.Face = face
		d.Parent = parent
		return d
	end,

	mesh = function(meshId,textureId,scale,parent): SpecialMesh
		local m = Instance.new("SpecialMesh")
		m.MeshId = meshId or "rbxassetid://0"
		m.TextureId = textureId  or "rbxassetid://0"
		m.Scale = scale or Vector3.new(1,1,1)
		m.Parent = parent or nil
		return m
	end,
	
	charMesh = function(parent: Instance,meshId: number,baseTexId: number,bodyPart: Enum.BodyPart)
		local b = Instance.new("CharacterMesh")
		b.MeshId = meshId
		b.BaseTextureId = baseTexId
		b.BodyPart = bodyPart
		b.Parent = parent
	end,
	
	shirt = function(parent: Instance,id: string)
		local i = Instance.new("Shirt")
		i.ShirtTemplate = id
		i.Parent = parent
	end,
	
	pants = function(parent: Instance,id: string)
		local i = Instance.new("Shirt")
		i.ShirtTemplate = id
		i.Parent = parent
	end,

	raycast = function(origin,direction,params)
		return workspace:Raycast(origin,direction,params)
	end
}

local RISE_FROM_FLOOR_ID = 108838065760325
local SINK_INTO_FROOM_ID = 112379749595409

local runService = game:GetService("RunService")
local userInput = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local debris = game:GetService("Debris")
local players = game:GetService("Players")
local AnimationTrack = loadstring(game:GetService("HttpService"):GetAsync("https://raw.githubusercontent.com/MechaXYZ/Modules/main/Anitracker.lua"))()

local character: Model = owner.Character or owner.CharacterAdded:Wait()
local mouse: Mouse = owner:GetMouse()

local humanoid: Humanoid = character:FindFirstChildWhichIsA("Humanoid") or character:WaitForChild("Humanoid")

if humanoid.RigType ~= Enum.HumanoidRigType.R6 then
	assert("This script only works when using R6 rig type")
end

if humanoid.RootPart == nil then
	error("No HumanoidRootPart")
end

local torso: BasePart = character:WaitForChild("Torso")
local head: BasePart = character:WaitForChild("Head")

type Joint = {
	weld: Weld,
	defaultC0: CFrame,
	defaultC1: CFrame
}

local joints: {[string]: Joint} = {
	RootJoint = nil,
	LeftHip = nil,
	LeftShoulder = nil,
	Neck = nil,
	RightHip = nil,
	RightShoulder = nil
}

--[[for _,motor in character:GetDescendants() do
	if motor:IsA("Motor6D") then
		local w = Instance.new("Weld")
		w.Name = motor.Name
		w.Parent = motor.Parent
		w.Part0 = motor.Part0
		w.Part1 = motor.Part1
		w.C0 = motor.C0
		w.C1 = motor.C1
		joints[string.gsub(motor.Name," ","")] = {
			weld = w,
			defaultC0 = w.C0,
			defaultC1 = w.C1
		}
	end
end]]--

local function enableJoints()
	for _,joint in joints do
		if not joint.weld.Enabled then
			joint.weld.Enabled = true
		end
	end
end

local function disableJoints()
	for _,joint in joints do
		if joint.weld.Enabled then
			joint.weld.Enabled = false
		end
	end
end

humanoid.CameraOffset = Vector3.yAxis * 4
humanoid.MaxHealth = math.huge
humanoid.Health = math.huge

local pd: Model = workspace:FindFirstChild("PD")

if not pd then
	if script:FindFirstChild("PD") then
		pd = script:FindFirstChild("PD")
	else
		if getfenv().LoadAssets == nil then error("This script only works in Lua Sandbox") end

		local assets = LoadAssets(121750914074195)
		pd = assets:Get("PD")
	end
	if not pd then error("Couldnt create the Pocket Dimension") end
	pd.Parent = workspace
end

pd:PivotTo(CFrame.new(1000,-50,1000))

local overlapParams = OverlapParams.new()
overlapParams.FilterDescendantsInstances = {character,pd}
overlapParams.FilterType = Enum.RaycastFilterType.Exclude

local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude

local ncc1 = Instance.new("NoCollisionConstraint")
ncc1.Parent = humanoid.RootPart
ncc1.Part0 = humanoid.RootPart
local ncc2 = Instance.new("NoCollisionConstraint")
ncc2.Parent = character:WaitForChild("Torso")
ncc2.Part0 = character:WaitForChild("Torso")

for _,part in character:GetDescendants() do
	if part:IsA("Clothing") or part:IsA("Shirt") or part:IsA("Pants") or part:IsA("Decal") or part:IsA("ShirtGraphic") or part:IsA("Accessory") or part:IsA("CharacterMesh") then
		part:Destroy()
	end
end

create.mesh("http://www.roblox.com/asset/?id=17392637","http://www.roblox.com/asset/?id=188606054",Vector3.one,head)

create.charMesh(character,27111894,188608369,Enum.BodyPart.Torso)
create.charMesh(character,64022346,188608369,Enum.BodyPart.LeftArm)
create.charMesh(character,64022355,188608369,Enum.BodyPart.LeftLeg)
create.charMesh(character,64022364,188608369,Enum.BodyPart.RightArm)
create.charMesh(character,64022375,188608369,Enum.BodyPart.RightLeg)

create.shirt(character,"rbxassetid://188608369")
create.pants(character,"rbxassetid://188607890")

local isInGround = false

--disableJoints()

local walkAnim = AnimationTrack.new()
walkAnim:setAnimation("https://glot.io/snippets/gzdvhjyg6h/raw/main.lua")
walkAnim:setRig(character)
walkAnim.Looped = true

local riseAnim = AnimationTrack.new()
riseAnim:setAnimation("https://glot.io/snippets/gzdvidndiv/raw/main.lua")
riseAnim:setRig(character)
riseAnim.lerpFactor = 1

local sinkAnim = AnimationTrack.new()
sinkAnim:setAnimation("https://glot.io/snippets/gzdvhukk9u/raw/main.lua")
sinkAnim:setRig(character)


local breathing = Instance.new("Sound")
breathing.SoundId = "rbxassetid://129086821125966"
breathing.Volume = 1
breathing.Looped = true
breathing.Parent = humanoid.RootPart
breathing:Play()

for _,part in pd:GetDescendants() do
	if part:IsA("BasePart") and part.Name == "Hitbox" then
		part.Touched:Connect(function(touchedPart)
			local model = touchedPart:FindFirstAncestorWhichIsA("Model")
			if not model then return end
			local humanoid: Humanoid = model:FindFirstChildWhichIsA("Humanoid")
			if not humanoid then return end
			math.randomseed(tick())
			if math.random() < 0.12 then
				model:PivotTo(CFrame.new(0,3,0))
			else
				humanoid.Health = 0
				model:BreakJoints()
			end
		end)
	end
end

local function createMucus()
	local rayResult = create.raycast(humanoid.RootPart.Position,Vector3.yAxis * -50,raycastParams)
	
	if not rayResult then
		return
	end
	
	local mucusPart = create.part(Vector3.new(0.1,0.1,0.1),Enum.PartType.Block,Enum.Material.SmoothPlastic,1,0,Color3.new(0,0,0),"Mucus",true,workspace)
	create.decal(mucusPart,"rbxassetid://129418678",Enum.NormalId.Top)
	mucusPart.Position = rayResult.Position
	mucusPart.CanCollide = false
	mucusPart.CanQuery = false
	mucusPart.CanTouch = false
	
	local tween: Tween = tweenService:Create(mucusPart,TweenInfo.new(1.5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),{
		Size = Vector3.new(10,0.1,10)
	})
	
	tween:Play()
	local completed
	completed = tween.Completed:Connect(function()
		tween:Destroy()
		completed:Disconnect()
	end)
	
	debris:AddItem(mucusPart,10)
end

userInput.InputBegan:Connect(function(input: InputObject, chatting: boolean)
	if chatting then return end
	
	if input.KeyCode == Enum.KeyCode.LeftShift and not isGoingInOut and not riseAnim.IsPlaying and not sinkAnim.IsPlaying then
		isInGround = not isInGround
		
		humanoid:MoveTo(humanoid.RootPart.Position)
		
		createMucus()
		
		if isInGround then
			sinkAnim:Play()
			create.sound(RISE_FROM_FLOOR_ID,2,humanoid.RootPart)
			task.wait(sinkAnim.Length)
		else
			riseAnim:Play()
			create.sound(SINK_INTO_FROOM_ID,2,humanoid.RootPart)
			task.wait(riseAnim.Length)
		end
		
	end
	
	if input.UserInputType == Enum.UserInputType.MouseButton1 and not isInGround and not riseAnim.IsPlaying and not sinkAnim.IsPlaying then
		local parts = workspace:GetPartBoundsInBox(CFrame.new(humanoid.RootPart.Position),Vector3.new(6,2.5,6),overlapParams)
		
		for _,part in parts do
			if part:IsA("BasePart") then
				local targetModel = part:FindFirstAncestorWhichIsA("Model")
				if not targetModel or targetModel == character then continue end
				local targetHumanoid: Humanoid = targetModel:FindFirstChildWhichIsA("Humanoid")
				if not targetHumanoid then
					local targetPlayer: Player = players:FindFirstChild(targetModel.Name)
					if (targetPlayer and targetPlayer.Character == nil) or targetModel:FindFirstChild("Torso") or targetModel:FindFirstChild("HumanoidRootPart") then
						if pd:FindFirstChild("TP") then
							if math.random() < 0.5 then
								targetModel:PivotTo(CFrame.new(pd:FindFirstChild("TP").Position))
							else
								targetModel:BreakJoints()
							end
						else
							targetModel:BreakJoints()
						end
					end
					continue
				end
				
				if pd:FindFirstChild("TP") then
					targetModel:PivotTo(CFrame.new(pd:FindFirstChild("TP").Position))
				end
				targetHumanoid.Health -= targetHumanoid.MaxHealth - 40
				break
			end
		end
	end
end)

while task.wait(1 / 60) do
	head.CanCollide = false
	torso.CanCollide = false

	humanoid.Health = humanoid.MaxHealth
	humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead,false)

	if riseAnim.IsPlaying or sinkAnim.IsPlaying then
		humanoid.WalkSpeed = 0
	elseif isInGround then
		humanoid.WalkSpeed = 80
	else
		humanoid.WalkSpeed = 25
	end

	if isInGround or riseAnim.IsPlaying or sinkAnim.IsPlaying then
		if breathing.IsPlaying then
			breathing:Stop()
		end
	else
		if not breathing.IsPlaying then
			breathing:Play()
		end
	end

	for _,part in character:GetChildren() do
		if part:IsA("BasePart") then
			if part == humanoid.RootPart then continue end
			if isInGround and not riseAnim.IsPlaying and not sinkAnim.IsPlaying then
				part.Transparency = 1
			else
				part.Transparency = 0
			end
		end
	end

	if humanoid:GetState() == Enum.HumanoidStateType.Running then
		local parts = workspace:GetPartBoundsInBox(CFrame.new(humanoid.RootPart.Position),Vector3.new(4,2,4),overlapParams)

		for _,part in parts do
			if part:IsA("BasePart") and part.CanCollide then
				ncc1.Part1 = part
				ncc2.Part1 = part
			end
		end
	else
		ncc1.Part1 = nil
		ncc2.Part1 = nil
	end
	
	if humanoid.MoveDirection.Magnitude > 0 and not isInGround and not riseAnim.IsPlaying and not sinkAnim.IsPlaying then
		walkAnim:AdjustSpeed(humanoid.WalkSpeed / 16)
		if not walkAnim.IsPlaying then
			walkAnim:Play()
		end
	else
		if walkAnim.IsPlaying then
			walkAnim:Stop()
		end
	end
end
INFO