--[[
Original Sonic Script with Sprint Button & Glitch Fix
]]
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera
-- Create Sprint Button
local screenGui = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
local btn = Instance.new("TextButton", screenGui)
btn.Size = UDim2.new(0, 80, 0, 80)
btn.Position = UDim2.new(0.8, 0, 0.7, 0)
btn.BackgroundColor3 = Color3.fromRGB(0, 120, 255)
btn.Text = "RUN"
btn.TextColor3 = Color3.new(1,1,1)
btn.Font = Enum.Font.FredokaOne
btn.TextSize = 25
Instance.new("UICorner", btn).CornerRadius = UDim.new(1, 0)
local function initSonic(char)
task.wait(0.5)
local hum = char:WaitForChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart")
-- Sprint Logic (Speed 67 + FOV 100)
btn.MouseButton1Down:Connect(function()
hum.WalkSpeed = 67
TweenService:Create(camera, TweenInfo.new(0.3), {FieldOfView = 100}):Play()
end)
btn.MouseButton1Up:Connect(function()
hum.WalkSpeed = 16
TweenService:Create(camera, TweenInfo.new(0.3), {FieldOfView = 70}):Play()
end)
if root:FindFirstChild("SonicRoot") then root.SonicRoot:Destroy() end
local sprites = {
idle = "rbxassetid://98630909487817",
walk = {"rbxassetid://100186283005430", "rbxassetid://74520657580881", "rbxassetid://121565656917719"},
run = {"rbxassetid://132396712896037", "rbxassetid://139692518360487", "rbxassetid://93868266127173", "rbxassetid://117677156233751"},
jump = {"rbxassetid://118861123713099", "rbxassetid://76937403052942", "rbxassetid://130530288388496"}
}
local function hide()
for _, v in pairs(char:GetDescendants()) do
if (v:IsA("BasePart") and v.Name ~= "HumanoidRootPart") or v:IsA("Decal") then
v.Transparency = 1
end
end
end
hide()
local main = Instance.new("BillboardGui", root)
main.Name = "SonicRoot"
main.Size = UDim2.new(5, 0, 5, 0)
main.AlwaysOnTop = false
main.ExtentsOffset = Vector3.new(0, 0.8, 0)
local img = Instance.new("ImageLabel", main)
img.AnchorPoint = Vector2.new(0.5, 0.5) -- CRITICAL: Stops the jumping/glitching
img.Position = UDim2.new(0.5, 0, 0.5, 0)
img.Size = UDim2.new(1, 0, 1, 0)
img.BackgroundTransparency = 1
img.ResampleMode = Enum.ResamplerMode.Pixelated
img.ScaleType = Enum.ScaleType.Fit
local frame, timer, fps = 1, 0, 12
RunService.Heartbeat:Connect(function(dt)
if not char.Parent then return end
timer = timer + dt
if timer >= (1/fps) then
timer = 0
frame = frame + 1
end
local vel = root.AssemblyLinearVelocity * Vector3.new(1, 0, 1)
local speed = vel.Magnitude
local state = hum:GetState()
-- Animation Picker
if state == Enum.HumanoidStateType.Jumping or state == Enum.HumanoidStateType.Freefall or state == Enum.HumanoidStateType.FallingDown then
fps = 16
if frame > #sprites.jump then frame = 1 end
img.Image = sprites.jump[frame]
elseif speed > 20 then
fps = 20
if frame > #sprites.run then frame = 1 end
img.Image = sprites.run[frame]
elseif speed > 1 then
fps = 10
if frame > #sprites.walk then frame = 1 end
img.Image = sprites.walk[frame]
else
img.Image = sprites.idle
frame = 1
end
-- Smooth Facing Logic (Fixes the flicker)
local move = hum.MoveDirection
if move.Magnitude > 0.1 then
local localMove = camera.CFrame:VectorToObjectSpace(move)
if localMove.X > 0.2 then
img.Size = UDim2.new(-1, 0, 1, 0)
elseif localMove.X < -0.2 then
img.Size = UDim2.new(1, 0, 1, 0)
end
end
end)
end
if player.Character then task.spawn(initSonic, player.Character) end
player.CharacterAdded:Connect(initSonic)
Comments
No comments yet
Be the first to share your thoughts!