Last active
February 6, 2025 22:04
-
-
Save ForNowImHere/02cd2a73b859fdbe6227581e5629d886 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local UserInputService = game:GetService("UserInputService") | |
local Players = game:GetService("Players") | |
local RunService = game:GetService("RunService") | |
local LocalPlayer = Players.LocalPlayer | |
local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait() | |
local humanoid = character:WaitForChild("Humanoid") | |
local characterRootPart = character:WaitForChild("HumanoidRootPart") | |
local camera = workspace.CurrentCamera | |
local StarterGui = game:GetService("StarterGui") | |
local baseFlingForce = 20000 -- Base force level | |
local additionalForce = 0 -- Additional force accumulated | |
local maxAdditionalForce = 200000000000 -- Maximum additional force | |
local forceIncrement = 10 -- Force increment per frame | |
local isMouseHeld = false -- Track if F key is held | |
-- Create a red bar in the GUI | |
local screenGui = Instance.new("ScreenGui", StarterGui) | |
local redBar = Instance.new("Frame", screenGui) | |
redBar.BackgroundColor3 = Color3.new(1, 0, 0) | |
redBar.Size = UDim2.new(0.1, 0, 0, 0) -- Initial size | |
redBar.Position = UDim2.new(0.9, 0, 0.5, 0) -- Position in the middle right | |
redBar.Visible = false -- Start as invisible | |
-- Function to handle player input for jump | |
local function onJumpInput(input, gameProcessed) | |
if gameProcessed then return end | |
if input.KeyCode == Enum.KeyCode.F then -- F key | |
isMouseHeld = true | |
redBar.Visible = true -- Make the red bar visible | |
end | |
end | |
-- Function to handle input end for jump | |
local function onJumpInputEnd(input, gameProcessed) | |
if gameProcessed then return end | |
if input.KeyCode == Enum.KeyCode.F then -- F key | |
isMouseHeld = false | |
-- Calculate the fling direction based on the camera's direction | |
local flingDirection = camera.CFrame.LookVector | |
local velocity = Instance.new("BodyVelocity") | |
velocity.Velocity = flingDirection * (baseFlingForce + additionalForce) | |
velocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge) | |
velocity.Parent = characterRootPart | |
-- Make the player stand | |
characterRootPart.CFrame = characterRootPart.CFrame * CFrame.Angles(0, 0, 0) | |
task.wait(0.5) | |
velocity:Destroy() | |
-- Any part that you touch while flinging other than any in FLOOR model will be unanchored on touch | |
characterRootPart.Touched:Connect(function(hit) | |
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= character.Name and hit.Parent.Parent.Name ~= "FLOOR" then | |
hit.Anchored = false | |
end | |
end) | |
-- Reset additional force | |
additionalForce = 0 | |
-- Reset the red bar size and make it invisible | |
redBar.Size = UDim2.new(0.10, 0, 0, 0) | |
redBar.Visible = false | |
end | |
end | |
-- Function to accumulate force while F key is held | |
local function accumulateForce() | |
if isMouseHeld and additionalForce < maxAdditionalForce then | |
additionalForce = additionalForce + forceIncrement | |
-- Update the red bar size | |
redBar.Size = UDim2.new(0.10, 0, additionalForce / maxAdditionalForce, 0) | |
end | |
end | |
-- Connect the onJumpInput function to the UserInputService | |
UserInputService.InputBegan:Connect(onJumpInput) | |
UserInputService.InputEnded:Connect(onJumpInputEnd) | |
-- Connect the accumulateForce function to the Heartbeat event | |
RunService.Heartbeat:Connect(accumulateForce) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment