SETUP:
If the Bandage is Equipped or Activated than disable the Sprinting State and Visibility set to false for the Sprint Button (Player can’t hold “Shift” Key to Sprint and interact with Sprint Button.)
<>
If the Bandage is Unequipped or Deactivated than enable the Sprinting State and Visibility set to true for the Sprint Button (Player can hold “Shift” Key to Sprint and interact with Sprint Button.)
Bandage Client Script:
local Debris = game:GetService("Debris")
local TS = game:GetService("TweenService")
local UIS = game:GetService("UserInputService")
local SGui = game:GetService("StarterGui")
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Mouse = Player:GetMouse()
local MouseIcon = "rbxasset://textures/GunCursor.png"
local ReloadingIcon = "rbxasset://textures/GunWaitCursor.png"
local Tool = script.Parent
local Handle = Tool:FindFirstChild("Handle")
local PlayerGui = Player:WaitForChild("PlayerGui")
local Events = Tool:FindFirstChild("Events")
local HealEvent = Events:FindFirstChild("Heal")
local Animations = Tool:FindFirstChild("Animations")
local HealAnimation = Humanoid:LoadAnimation(Animations:FindFirstChild("Heal"))
local HealSound = Handle:FindFirstChild("Healing")
local BandageGui = Tool:FindFirstChild("BandageGui")
local Settings = require(Tool:FindFirstChild("Settings"))
Tool.Equipped:Connect(function()
BandageGui.Parent = PlayerGui
BandageGui.Enabled = true
Mouse.Icon = MouseIcon
UIS.MouseIconEnabled = true
Humanoid.Health = 5 -- Testing purposes
local message = BandageGui:FindFirstChild("BandageMessage")
local frame = BandageGui:FindFirstChild("BandageFrame")
if Humanoid.Health >= Humanoid.MaxHealth then
if message then
message.Visible = false
end
if frame then
frame.Visible = false
end
end
end)
Tool.Unequipped:Connect(function()
BandageGui.Parent = Tool
Mouse.Icon = ""
end)
local function FadeUI(container, targetTransparency, duration)
if not container then return end
for _, obj in ipairs(container:GetDescendants()) do
if obj:IsA("Frame") or obj:IsA("TextLabel") or obj:IsA("ImageLabel") then
local props = {}
if obj:IsA("Frame") or obj:IsA("ImageLabel") then
props.BackgroundTransparency = targetTransparency
if obj:IsA("ImageLabel") then
props.ImageTransparency = targetTransparency
end
end
if obj:IsA("TextLabel") then
props.TextTransparency = targetTransparency
end
TS:Create(obj, TweenInfo.new(duration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), props):Play()
end
end
end
Tool.Activated:Connect(function()
local message = BandageGui:FindFirstChild("BandageMessage")
local frame = BandageGui:FindFirstChild("BandageFrame")
local fill = frame and frame:FindFirstChild("Fill")
BandageGui.Parent = PlayerGui
BandageGui.Enabled = true
frame.Visible = false
if Humanoid.Health >= Humanoid.MaxHealth then
if not Settings.Cooldown and message then
Settings.Cooldown = true
message.Text = "Can't use Bandage (Max Health)"
message.Visible = true
message.TextTransparency = 0
message.BackgroundTransparency = 0.5
task.wait(0.5)
TS:Create(message, TweenInfo.new(1), {
TextTransparency = 1,
BackgroundTransparency = 1
}):Play()
task.delay(1.5, function()
Settings.Cooldown = false
end)
end
if frame then
frame.Visible = false
end
return
else
if message then message.Visible = false end
if frame then
frame.Visible = true
FadeUI(frame, 0.5, 0.2)
end
end
if not Settings.Debounce then
Settings.Healing = true
Settings.Debounce = true
Mouse.Icon = ReloadingIcon
SGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
if not HealAnimation.IsPlaying then HealAnimation:Play() end
if not HealSound.IsPlaying then HealSound:Play() end
local healthPercentage = Humanoid.Health / Humanoid.MaxHealth
local healProgress = (Humanoid.Health + Settings.Heal.Max) / Humanoid.MaxHealth
local fillDuration = math.clamp(3.7 * (2 - healProgress), 4, 30)
local FillTween = fill and TS:Create(fill, TweenInfo.new(fillDuration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Size = UDim2.new(1, 0, 1, 0)})
Humanoid.WalkSpeed = 6
if FillTween then FillTween:Play() end
local elapsed = 0
local step = 0.1
while elapsed < Settings.HealTime do
if not Settings.Healing then
if FillTween then FillTween:Cancel() end
if fill then
fill.Size = UDim2.new(0, 0, 1, 0)
end
break
end
task.wait(step)
elapsed += step
end
if Settings.Healing then
if fill then
fill.Size = UDim2.new(0, 0, 1, 0)
end
end
FadeUI(frame, 1, 0.2)
task.delay(0, function()
if frame then frame.Visible = false end
end)
if Settings.Healing then
HealEvent:FireServer(35)
end
Settings.Healing = false
Settings.Debounce = false
HealAnimation:Stop()
HealSound:Stop()
Humanoid.WalkSpeed = 16
SGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
end
end)
Tool.Deactivated:Connect(function()
local frame = BandageGui:FindFirstChild("BandageFrame")
local fill = frame and frame:FindFirstChild("Fill")
if Settings.Healing then
if frame then
FadeUI(frame, 1, 0.2)
task.delay(0.2, function()
if frame then frame.Visible = false end
end)
end
if fill then
fill.Size = UDim2.new(0, 0, 1, 0)
end
Settings.Healing = false
Settings.Debounce = false
HealAnimation:Stop()
HealSound:Stop()
Humanoid.WalkSpeed = 16
SGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
UIS.MouseIconEnabled = true
Mouse.Icon = MouseIcon
end
end)
Sprint Module:
local Sprint = {}
Sprint.__index = Sprint
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local Settings = require(game:GetService("StarterPlayer").StarterPlayerScripts.Settings)
local Player = Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local Camera = workspace.CurrentCamera
local SprintGui = script:WaitForChild("SprintGui")
local SprintButton = SprintGui:WaitForChild("SprintButton")
SprintGui.Parent = PlayerGui
Sprint.BobbingIntensity = {
Walking = 0.05,
Sprinting = 0.08,
}
function Sprint:Initialize()
local function ResetOnRespawn()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
Settings.Sprinting = false
Humanoid.WalkSpeed = Settings.WalkSpeed
self:TweenFOV(70)
self.Humanoid = Humanoid
self.HumanoidRootPart = HumanoidRootPart
end
ResetOnRespawn()
Player.CharacterAdded:Connect(ResetOnRespawn)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
self:OnInputBegan(input)
end
end)
UserInputService.InputEnded:Connect(function(input, gameProcessed)
if not gameProcessed then
self:OnInputEnded(input)
end
end)
SprintButton.MouseButton1Down:Connect(function()
self:StartSprinting()
end)
SprintButton.MouseButton1Up:Connect(function()
self:StopSprinting()
end)
end
function Sprint:OnInputBegan(input)
if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.LeftShift then
self:StartSprinting()
end
end
function Sprint:OnInputEnded(input)
if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.LeftShift then
self:StopSprinting()
end
end
function Sprint:StartSprinting()
if not Settings.Sprinting then
Settings.Sprinting = true
self.Humanoid.WalkSpeed = Settings.SprintSpeed
if self.Humanoid.MoveDirection.Magnitude > 0 then
self:TweenFOV(80)
end
end
end
function Sprint:StopSprinting()
if Settings.Sprinting then
Settings.Sprinting = false
self.Humanoid.WalkSpeed = Settings.WalkSpeed
self:TweenFOV(70)
end
end
function Sprint:TweenFOV(targetFOV)
if Settings.Sprinting or targetFOV == 70 then
local info = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local properties = { FieldOfView = targetFOV }
local tween = TweenService:Create(Camera, info, properties)
tween:Play()
end
end
function Sprint:UpdateCamera(DeltaTime)
if not self.Humanoid or not self.HumanoidRootPart then return end
local IsMoving = self.Humanoid.MoveDirection.Magnitude > 0.01
local IsSprinting = self.Humanoid.WalkSpeed >= Settings.SprintSpeed
local WalkOrSprintState = IsSprinting and "Sprinting" or "Walking"
local CurrentIntensity = self.BobbingIntensity[WalkOrSprintState] or self.BobbingIntensity.Walking
local MoveDirection = self.Humanoid.MoveDirection
local FacingDirection = self.HumanoidRootPart.CFrame.LookVector
if IsMoving then
Settings.Bobbing = Settings.Bobbing:Lerp(
CFrame.Angles(
math.rad(math.sin(time() * 20) * CurrentIntensity),
math.rad(math.sin(time() * 10) * CurrentIntensity),
math.rad(-math.round(MoveDirection:Dot(Camera.CFrame.RightVector)) * CurrentIntensity)
),
0.3
)
else
Settings.Bobbing = CFrame.new()
end
Camera.CFrame = Camera.CFrame * Settings.Bobbing
end
RunService.RenderStepped:Connect(function(DeltaTime)
Sprint:UpdateCamera(DeltaTime)
end)
return Sprint
Settings Module:
return {
-- Sprint Settings
Sprinting = false;
MovingBackward = false;
Bobbing = CFrame.new();
DeltaTime = 1 / 60;
WalkSpeed = 16;
SprintSpeed = 25;
-- Ability Settings
Ability = true;
CurrentTime = tick();
Cooldown = 60;
HighlightCooldown = 10;
-- Menu Settings
Debounce = false;
MaxTilt = 10;
FadeTime = 2.7;
-- Zones Settings
Teleported = false;
TeleportCooldown = 2;
TeleportTime = 0;
TerrainHeight = 20;
-- ShiftLock Settings
MaxAttempts = 2;
Attempt = 0;
-- Other Settings
}
I’m still learning scripting so please explain in addition to a newbie, thank you!