local Tool = Instance.new("Part")
local Player = game.Players.LocalPlayer
local CachedGooProperties = {BrickColor.new("Black"), Enum.PartType.Cylinder, Vector3.new(1, 3, 1), Enum.Material.Foil, true, Vector3.new(0, 90, 90)}
local IsGooey = true
local WASD_DOWN = {false,false,false,false}
local global_Goo = Instance.new("Part")
local GooGui = Instance.new("ScreenGui")
local SOTPBUTTON = Instance.new("TextButton")
local Character = game.Players.LocalPlayer.Character
local JUSTLISTEN
GooGui.Name = "GooGui"
GooGui.Parent = Player.PlayerGui
GooGui.Enabled = false
SOTPBUTTON.Parent = GooGui
SOTPBUTTON.Text = "StopGoo"
SOTPBUTTON.AnchorPoint = Vector2.new(1,0)
SOTPBUTTON.Position = UDim2.new(1,0,0,0)
SOTPBUTTON.Size = UDim2.new(0.2,0,0.1,0)
SOTPBUTTON.BackgroundColor3 = Color3.new(1,0,0)
SOTPBUTTON.TextColor3 = Color3.new(1,1,1)
SOTPBUTTON.Font = Enum.Font.JosefinSans
SOTPBUTTON.TextScaled = true

function createTool()
	Tool = Instance.new("Tool")
	Tool.Parent = Player.Backpack
	Tool.Name = "Transform"
	Tool.ToolTip = "Into Goo"
	Tool.RequiresHandle = false
	Tool.CanBeDropped = true
	print("Poision in that gumbo")
	return Tool
end

JUSTLISTEN = createTool()

JUSTLISTEN.Activated:Connect(function()
	print("Emotion feel dumbo")
	local Goo = Instance.new("Part")
	local ParticleEmitter = Instance.new("ParticleEmitter")
	Player.Character.Parent = game.ReplicatedStorage
	global_Goo = Goo
	IsGooey = true
	Goo.Name = "HumanoidRootPart"
	Goo.Parent = workspace
	Goo.BrickColor = CachedGooProperties[1]
	Goo.Shape = CachedGooProperties[2]
	Goo.Size = CachedGooProperties[3]
	Goo.Material = CachedGooProperties[4]
	Goo.CanCollide = CachedGooProperties[5]
	Goo.Anchored = CachedGooProperties[5]
	Goo.Orientation = CachedGooProperties[6]
	Goo.Position = Player.Character.HumanoidRootPart.Position - Vector3.new(0, Player.Character.Humanoid.HipHeight, 0)
	Goo.Position = workspace:Raycast(Goo.Position, Vector3.new(0,-100,0)).Position
	Goo.Parent = workspace
	game.Workspace.CurrentCamera.CameraSubject = Goo
	game:GetService("TweenService"):Create(Goo, TweenInfo.new(1, Enum.EasingStyle.Circular), {Size = Vector3.new(0.1, 4, 4)}):Play()
	ParticleEmitter.Color = ColorSequence.new(Color3.new(0,0,0))
	ParticleEmitter.Size = NumberSequence.new(1.7,0)
	ParticleEmitter.Texture = 'rbxassetid://16105515170'
	ParticleEmitter.Brightness = 0
	ParticleEmitter.LightInfluence = 0
	ParticleEmitter.Speed = NumberRange.new(0)
	ParticleEmitter.Rate = 65
	ParticleEmitter.Lifetime = NumberRange.new(1)
	ParticleEmitter.Shape = Enum.ParticleEmitterShape.Cylinder
	ParticleEmitter.ShapeInOut = Enum.ParticleEmitterShapeInOut.Inward
	ParticleEmitter.Parent = Goo
	task.delay(1, function()
		GooGui.Enabled = true
	end)
	Player.Character.Humanoid.Sit = true

end)

game:GetService("UserInputService").InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.W then
		WASD_DOWN[1] = true
	end
	if key.KeyCode == Enum.KeyCode.A then
		WASD_DOWN[2] = true
	end
	if key.KeyCode == Enum.KeyCode.S then
		WASD_DOWN[3] = true
	end
	if key.KeyCode == Enum.KeyCode.D then
		WASD_DOWN[4] = true
	end
end)
game:GetService("UserInputService").InputEnded:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.W then
		WASD_DOWN[1] = false
	end
	if key.KeyCode == Enum.KeyCode.A then
		WASD_DOWN[2] = false
	end
	if key.KeyCode == Enum.KeyCode.S then
		WASD_DOWN[3] = false
	end
	if key.KeyCode == Enum.KeyCode.D then
		WASD_DOWN[4] = false
	end
end)

game:GetService("RunService").PreRender:Connect(function()
	if IsGooey == true then
		local camera_reference = Instance.new("Part")
		camera_reference.CFrame = workspace.CurrentCamera.CFrame
		global_Goo.Orientation = Vector3.new(0, camera_reference.Orientation.Y, 90)
		camera_reference:Destroy()
		if WASD_DOWN[1] then
			global_Goo.Position += global_Goo.CFrame.LookVector
		end
		if WASD_DOWN[2] then
			global_Goo.Position += global_Goo.CFrame.UpVector
		end
		if WASD_DOWN[3] then
			global_Goo.Position += global_Goo.CFrame.ZVector
		end
		if WASD_DOWN[4] then
			global_Goo.Position -= global_Goo.CFrame.UpVector
		end
	end
end)

SOTPBUTTON.MouseButton1Click:Connect(function()
	Player.Character = Character
	game:GetService("TweenService"):Create(Player.Character.HumanoidRootPart, TweenInfo.new(1, Enum.EasingStyle.Circular), {CFrame = CFrame.new(global_Goo.Position) }):Play()
	wait(1)
	Player.Character.Parent = game.Workspace
	Player.Character.Humanoid.Sit = false
	game.Workspace.CurrentCamera.CameraSubject = Player.Character.Humanoid
	global_Goo:Destroy()
	global_Goo = Instance.new("Part")
end)