Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- LocalScript
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- local terrain = workspace.Terrain
- -- Animation IDs
- local idleAnimationId = "rbxassetid://18622529913"
- local sprintAnimationId = "rbxassetid://2"
- -- Speeds
- local walkSpeed = 34
- local sprintSpeed = 60
- -- Deep blue color
- local deepBlue = BrickColor.new("Really blue")
- -- Load animations
- local idleAnimation = Instance.new("Animation")
- idleAnimation.AnimationId = idleAnimationId
- local idleTrack = humanoid:LoadAnimation(idleAnimation)
- local sprintAnimation = Instance.new("Animation")
- sprintAnimation.AnimationId = sprintAnimationId
- local sprintTrack = humanoid:LoadAnimation(sprintAnimation)
- -- Set idle animation
- humanoid.Running:Connect(function(speed)
- if speed < 0.1 then
- if not idleTrack.IsPlaying then
- idleTrack:Play()
- end
- else
- if idleTrack.IsPlaying then
- idleTrack:Stop()
- end
- end
- end)
- -- Permanently change body color to deep blue
- local function changeBodyColor(color)
- for _, partName in ipairs({"LeftArm", "RightArm", "LeftLeg", "RightLeg", "Head", "Torso", "RightHand", "LeftHand", "RightFoot", "LeftFoot", "UpperTorso", "LowerTorso"}) do
- local part = character:FindFirstChild(partName)
- if part and part:IsA("BasePart") then
- part.BrickColor = color
- end
- end
- end
- changeBodyColor(deepBlue)
- -- Handle sprinting
- local userInputService = game:GetService("UserInputService")
- local sprinting = false
- local function toggleSprint(isSprinting)
- if isSprinting then
- humanoid.WalkSpeed = sprintSpeed
- sprintTrack:Play()
- else
- humanoid.WalkSpeed = walkSpeed
- sprintTrack:Stop()
- end
- sprinting = isSprinting
- end
- userInputService.InputBegan:Connect(function(input)
- if input.KeyCode == Enum.KeyCode.LeftShift then
- toggleSprint(true)
- end
- end)
- userInputService.InputEnded:Connect(function(input)
- if input.KeyCode == Enum.KeyCode.LeftShift then
- toggleSprint(false)
- end
- end)
- -- Set initial walk speed
- humanoid.WalkSpeed = walkSpeed
- -- Check for water terrain and place part
- game:GetService("RunService").RenderStepped:Connect(function()
- if sprinting then
- local ray = Ray.new(character.HumanoidRootPart.Position, Vector3.new(0, -5, 0))
- local part, position = workspace:FindPartOnRayWithIgnoreList(ray, {character})
- 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
- local waterPart = Instance.new("Part")
- waterPart.Size = Vector3.new(5, 1, 5)
- waterPart.Anchored = true
- waterPart.CanCollide = true
- waterPart.Transparency = 1
- waterPart.Position = position + Vector3.new(0, -1, 0)
- waterPart.Parent = workspace
- -- Remove the part after a short delay
- game:GetService("Debris"):AddItem(waterPart, 0.1)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement