Advertisement
lllkkklkk

sonic V1

Jul 25th, 2024
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. -- LocalScript
  2.  
  3. local player = game.Players.LocalPlayer
  4. local character = player.Character or player.CharacterAdded:Wait()
  5. local humanoid = character:WaitForChild("Humanoid")
  6. local terrain = workspace.Terrain
  7.  
  8. -- Animation IDs
  9. local idleAnimationId = "rbxassetid://18622529913"
  10. local sprintAnimationId = "rbxassetid://2"
  11.  
  12. -- Speeds
  13. local walkSpeed = 34
  14. local sprintSpeed = 60
  15.  
  16. -- Deep blue color
  17. local deepBlue = BrickColor.new("Really blue")
  18.  
  19. -- Load animations
  20. local idleAnimation = Instance.new("Animation")
  21. idleAnimation.AnimationId = idleAnimationId
  22. local idleTrack = humanoid:LoadAnimation(idleAnimation)
  23.  
  24. local sprintAnimation = Instance.new("Animation")
  25. sprintAnimation.AnimationId = sprintAnimationId
  26. local sprintTrack = humanoid:LoadAnimation(sprintAnimation)
  27.  
  28. -- Set idle animation
  29. humanoid.Running:Connect(function(speed)
  30. if speed < 0.1 then
  31. if not idleTrack.IsPlaying then
  32. idleTrack:Play()
  33. end
  34. else
  35. if idleTrack.IsPlaying then
  36. idleTrack:Stop()
  37. end
  38. end
  39. end)
  40.  
  41. -- Permanently change body color to deep blue
  42. local function changeBodyColor(color)
  43. for _, partName in ipairs({"LeftArm", "RightArm", "LeftLeg", "RightLeg", "Head", "Torso", "RightHand", "LeftHand", "RightFoot", "LeftFoot", "UpperTorso", "LowerTorso"}) do
  44. local part = character:FindFirstChild(partName)
  45. if part and part:IsA("BasePart") then
  46. part.BrickColor = color
  47. end
  48. end
  49. end
  50.  
  51. changeBodyColor(deepBlue)
  52.  
  53. -- Handle sprinting
  54. local userInputService = game:GetService("UserInputService")
  55. local sprinting = false
  56.  
  57. local function toggleSprint(isSprinting)
  58. if isSprinting then
  59. humanoid.WalkSpeed = sprintSpeed
  60. sprintTrack:Play()
  61. else
  62. humanoid.WalkSpeed = walkSpeed
  63. sprintTrack:Stop()
  64. end
  65. sprinting = isSprinting
  66. end
  67.  
  68. userInputService.InputBegan:Connect(function(input)
  69. if input.KeyCode == Enum.KeyCode.LeftShift then
  70. toggleSprint(true)
  71. end
  72. end)
  73.  
  74. userInputService.InputEnded:Connect(function(input)
  75. if input.KeyCode == Enum.KeyCode.LeftShift then
  76. toggleSprint(false)
  77. end
  78. end)
  79.  
  80. -- Set initial walk speed
  81. humanoid.WalkSpeed = walkSpeed
  82.  
  83. -- Check for water terrain and place part
  84. game:GetService("RunService").RenderStepped:Connect(function()
  85. if sprinting then
  86. local ray = Ray.new(character.HumanoidRootPart.Position, Vector3.new(0, -5, 0))
  87. local part, position = workspace:FindPartOnRayWithIgnoreList(ray, {character})
  88. if part and part:IsA("Terrain") and terrain:ReadVoxels(Region3.new(position - Vector3.new(2, 2, 2), position + Vector3.new(2, 2, 2)), 4)[1][1][1] == Enum.Material.Water then
  89. local waterPart = Instance.new("Part")
  90. waterPart.Size = Vector3.new(5, 1, 5)
  91. waterPart.Anchored = true
  92. waterPart.CanCollide = true
  93. waterPart.Transparency = 1
  94. waterPart.Position = position + Vector3.new(0, -1, 0)
  95. waterPart.Parent = workspace
  96.  
  97. -- Remove the part after a short delay
  98. game:GetService("Debris"):AddItem(waterPart, 0.1)
  99. end
  100. end
  101. end)
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement