Pih
Key RequiredUniversal

Pih

Universal ScriptAstellAstell 435 views 40 executesUpdated Oct 21, 2025
Unrated
00
Lua Script•184 lines (6878 chars)
--[=[
 d888b  db    db d888888b      .d888b.      db      db    db  .d8b.  
88' Y8b 88    88   `88'        VP  `8D      88      88    88 d8' `8b 
88      88    88    88            odD'      88      88    88 88ooo88 
88  ooo 88    88    88          .88'        88      88    88 88~~~88 
88. ~8~ 88b  d88   .88.        j88.         88booo. 88b  d88 88   88    @uniquadev
 Y888P  ~Y8888P' Y888888P      888888D      Y88888P ~Y8888P' YP   YP  CONVERTER 
]=]

-- Instances: 6 | Scripts: 1 | Modules: 0 | Tags: 0
local G2L = {};

-- StarterGui.Pih
G2L["1"] = Instance.new("ScreenGui", game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"));
G2L["1"]["Name"] = [[Pih]];
G2L["1"]["ZIndexBehavior"] = Enum.ZIndexBehavior.Sibling;


-- StarterGui.Pih.boundary
G2L["2"] = Instance.new("Frame", G2L["1"]);
G2L["2"]["BorderSizePixel"] = 0;
G2L["2"]["BackgroundColor3"] = Color3.fromRGB(42, 37, 59);
G2L["2"]["ClipsDescendants"] = true;
G2L["2"]["Size"] = UDim2.new(0, 2560, 0, 1152);
G2L["2"]["BorderColor3"] = Color3.fromRGB(0, 0, 0);
G2L["2"]["Name"] = [[boundary]];
G2L["2"]["BackgroundTransparency"] = 1;


-- StarterGui.Pih.boundary.pih
G2L["3"] = Instance.new("ImageLabel", G2L["2"]);
G2L["3"]["BorderSizePixel"] = 0;
G2L["3"]["BackgroundColor3"] = Color3.fromRGB(255, 255, 255);
-- [ERROR] cannot convert ImageContent, please report to "https://github.com/uniquadev/GuiToLuaConverter/issues"
G2L["3"]["Image"] = [[rbxassetid://108917931816235]];
G2L["3"]["Size"] = UDim2.new(0, 129, 0, 100);
G2L["3"]["BorderColor3"] = Color3.fromRGB(0, 0, 0);
G2L["3"]["BackgroundTransparency"] = 1;
G2L["3"]["Name"] = [[pih]];
G2L["3"]["Position"] = UDim2.new(0.47461, 0, 0.46181, 0);


-- StarterGui.Pih.boundary.pih.ClickSound
G2L["4"] = Instance.new("Sound", G2L["3"]);
G2L["4"]["Name"] = [[ClickSound]];
G2L["4"]["SoundId"] = [[rbxassetid://8592530104]];


-- StarterGui.Pih.boundary.pih.Smooth GUI Dragging
G2L["5"] = Instance.new("LocalScript", G2L["3"]);
G2L["5"]["Name"] = [[Smooth GUI Dragging]];


-- StarterGui.Pih.boundary.UICorner
G2L["6"] = Instance.new("UICorner", G2L["2"]);
G2L["6"]["CornerRadius"] = UDim.new(0, 15);


-- StarterGui.Pih.boundary.pih.Smooth GUI Dragging
local function C_5()
local script = G2L["5"];
	local UserInputService = game:GetService("UserInputService")
	local RunService = game:GetService("RunService")
	local Players = game:GetService("Players")
	
	local player = Players.LocalPlayer
	local playerGui = player:WaitForChild("PlayerGui")
	local screenGui = playerGui:WaitForChild("Pih") -- Ensure ScreenGui exists in PlayerGui
	local frame = screenGui:WaitForChild("boundary") -- Frame to constrain the image
	local imageLabel = frame:WaitForChild("pih") -- Draggable ImageLabel
	
	-- Create or get the sound object
	local sound = imageLabel:FindFirstChild("ClickSound") or Instance.new("Sound", imageLabel)
	sound.Name = "ClickSound"
	sound.SoundId = "rbxassetid://8592530104" -- Default Roblox button press sound
	sound.Volume = 0.5
	sound.PlayOnRemove = false
	
	local dragging = false
	local dragStart = Vector2.new(0, 0)
	local startPos = Vector2.new(0, 0)
	local lastPos = Vector2.new(0, 0)
	local velocity = Vector2.new(0, 0)
	local isSliding = false
	local friction = 0.98 -- Friction for longer slide
	local velocityThreshold = 2 -- Threshold for slide duration
	local bounceFactor = 0.7 -- Bounce effect (0 to 1, lower means less bounce energy)
	
	-- Function to clamp the image position within the frame and handle bounce
	local function clampPosition(pos, applyBounce)
		local frameSize = frame.AbsoluteSize
		local framePos = frame.AbsolutePosition
		local imageSize = imageLabel.AbsoluteSize
	
		-- Calculate boundaries
		local minX = framePos.X
		local maxX = framePos.X + frameSize.X - imageSize.X
		local minY = framePos.Y
		local maxY = framePos.Y + frameSize.Y - imageSize.Y
	
		-- Clamp the position
		local clampedX = math.clamp(pos.X, minX, maxX)
		local clampedY = math.clamp(pos.Y, minY, maxY)
	
		-- Handle bounce if sliding and hitting a boundary
		if applyBounce then
			if pos.X <= minX or pos.X >= maxX then
				velocity = Vector2.new(-velocity.X * bounceFactor, velocity.Y)
				print("Bounce X: New velocity =", velocity)
			end
			if pos.Y <= minY or pos.Y >= maxY then
				velocity = Vector2.new(velocity.X, -velocity.Y * bounceFactor)
				print("Bounce Y: New velocity =", velocity)
			end
		end
	
		return Vector2.new(clampedX, clampedY)
	end
	
	-- Handle dragging start and play sound
	imageLabel.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
			dragging = true
			isSliding = false
			dragStart = input.Position
			startPos = imageLabel.AbsolutePosition
			lastPos = input.Position
			velocity = Vector2.new(0, 0)
			sound:Play() -- Play sound on click
			print("Drag started at", input.Position, "Sound played")
		end
	end)
	
	-- Handle dragging end
	imageLabel.InputEnded:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
			dragging = false
			isSliding = true
			print("Drag ended, sliding started with velocity =", velocity)
		end
	end)
	
	-- Update velocity during dragging
	UserInputService.InputChanged:Connect(function(input)
		if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
			local currentPos = input.Position
			local delta = input.Position - dragStart
			local newPos = Vector2.new(startPos.X + delta.X, startPos.Y + delta.Y)
			local clampedPos = clampPosition(newPos, false) -- No bounce during dragging
			imageLabel.Position = UDim2.new(0, clampedPos.X - frame.AbsolutePosition.X, 0, clampedPos.Y - frame.AbsolutePosition.Y)
	
			-- Calculate velocity (pixels per second)
			velocity = (currentPos - lastPos) / 0.016 -- Assume ~60 FPS
			lastPos = currentPos
			print("Dragging: Velocity =", velocity)
		end
	end)
	
	-- Handle sliding and bouncing
	RunService.Heartbeat:Connect(function(deltaTime)
		if isSliding then
			-- Apply velocity and friction
			local scaledVelocity = velocity * deltaTime -- Scale velocity for frame rate
			local currentPos = imageLabel.AbsolutePosition
			local newPos = currentPos + scaledVelocity
			local clampedPos = clampPosition(newPos, true) -- Apply bounce during sliding
			imageLabel.Position = UDim2.new(0, clampedPos.X - frame.AbsolutePosition.X, 0, clampedPos.Y - frame.AbsolutePosition.Y)
	
			-- Apply friction to slow down
			velocity = velocity * friction
			print("Sliding: Position =", clampedPos, "Velocity =", velocity)
	
			-- Stop sliding if velocity is too low
			if velocity.Magnitude < velocityThreshold then
				isSliding = false
				velocity = Vector2.new(0, 0)
				print("Sliding stopped")
			end
		end
	end)
end;
task.spawn(C_5);

return G2L["1"], require;

Features & Information

This script is a paradoxical enigma that shall never be truly deciphered...

Community Comments (1)

ALTERRATICALTERRATICOct 21, 2025

pih

More Scripts for Universal Scripts