Trouble making a slide script

Basically im making a slide “system”, where you press Q and you dash forward and an animation plays.
It works, but when i want it to have physics, it just bugs out and i dont know how i will get it to work.

task.spawn(function() -- attempt on trying to make it offset, note that this isn't the full script
	while gliding do
		local rayy = workspace:Raycast(hrp.Position, hrp.CFrame.UpVector * -11, params)
		visualizer:Raycast(hrp.Position, hrp.CFrame.UpVector * -100, params)
		     if rayy and rayy.Instance then
					hrp.CFrame = CFrame.lookAt(hrp.Position, hrp.Position + rayy.Normal)
						end
						task.wait()
					end
				end)

A short video demonstrating my problem: https://gyazo.com/5b1f77ea326ec8794b6e45501a2d328b
I want it so that players will ‘Rotate’ the same way a part is facing.

Images demonstrating my problem

Please help me

I still need help, im still searching for ways

1 Like

I made this dash script, just insert it as a local script under StarterCharacterScripts and it should work

local debounce = false

local function onKeyPress(input)
	if input == "q" then
		if debounce == false then
			debounce = true
			local humanoidRootPart = game.Players.LocalPlayer.Character.HumanoidRootPart
			local humanoid = game.Players.LocalPlayer.Character.Humanoid
			local anim = Instance.new("Animation")
			anim.AnimationId = "rbxassetid://18237726269"

			--Animate

			local playerAnims = humanoid.Animator:GetPlayingAnimationTracks() -- gets all Animations

			for _,animation in playerAnims do -- Iterates through all Animations
				print(animation)
				animation:Stop() -- stops animations
			end

			game.Players.LocalPlayer.Character["Animate"].Enabled = false



			local animationTrack = humanoid:LoadAnimation(anim)

			wait(0.01)

			animationTrack:Play()
			
			local DashParticle = Instance.new("ParticleEmitter")
			DashParticle.Texture = "rbxassetid://14197943648"
			DashParticle.Parent = game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
			DashParticle.EmissionDirection = "Back"
			DashParticle.Lifetime = NumberRange.new(0.5,1)
			DashParticle.Rate = 90
			DashParticle.Orientation = Enum.ParticleOrientation.VelocityParallel
			DashParticle.Speed = NumberRange.new(3)
			DashParticle.Squash = NumberSequence.new(-1.5)

			for i = 0,10,1 do -- move the player forward
				task.wait(0.00001)
				local currentCFrame = humanoidRootPart:GetPivot()
				local forwardVector = currentCFrame.LookVector * 2
				local targetCFrame = currentCFrame + forwardVector
				humanoidRootPart:PivotTo(targetCFrame)
			end
			
			DashParticle.Enabled = false
			
			wait(0.5)
			game.Players.LocalPlayer.Character["Animate"].Enabled = true
			wait(0.01)

			--Re-Enable Movement (Kind of hacky)
			game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").Jump = true
			task.wait(0.00001)
			humanoidRootPart.Velocity = Vector3.new(0,0,0)


		end
		wait(1) -- 1 second cool down
		debounce = false
	end


end
game.Players.LocalPlayer:GetMouse().KeyDown:Connect(onKeyPress) -- on key press

You might also want to add a button to the screen for mobile players. :blush:

Script with added mobile button! It only shows up on mobile btw. Just put everything under a localscript in the StarterCharacterScripts folder

local debounce = false
local UserInputService = game:GetService("UserInputService")

local function onKeyPress(input)
	if input == "q" then
		if debounce == false then
			debounce = true
			local humanoidRootPart = game.Players.LocalPlayer.Character.HumanoidRootPart
			local humanoid = game.Players.LocalPlayer.Character.Humanoid
			local anim = Instance.new("Animation")
			anim.AnimationId = "rbxassetid://18237726269"

			--Animate

			local playerAnims = humanoid.Animator:GetPlayingAnimationTracks() -- gets all Animations

			for _,animation in playerAnims do -- Iterates through all Animations
				print(animation)
				animation:Stop() -- stops animations
			end

			game.Players.LocalPlayer.Character["Animate"].Enabled = false



			local animationTrack = humanoid:LoadAnimation(anim)

			wait(0.01)

			animationTrack:Play()

			local DashParticle = Instance.new("ParticleEmitter")
			DashParticle.Texture = "rbxassetid://14197943648"
			DashParticle.Parent = game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
			DashParticle.EmissionDirection = "Back"
			DashParticle.Lifetime = NumberRange.new(0.5,1)
			DashParticle.Rate = 90
			DashParticle.Orientation = Enum.ParticleOrientation.VelocityParallel
			DashParticle.Speed = NumberRange.new(3)
			DashParticle.Squash = NumberSequence.new(-1.5)

			for i = 0,10,1 do -- move the player forward
				task.wait(0.00001)
				local currentCFrame = humanoidRootPart:GetPivot()
				local forwardVector = currentCFrame.LookVector * 2
				local targetCFrame = currentCFrame + forwardVector
				humanoidRootPart:PivotTo(targetCFrame)
			end

			DashParticle.Enabled = false

			wait(0.5)
			game.Players.LocalPlayer.Character["Animate"].Enabled = true
			wait(0.01)

			--Re-Enable Movement (Kind of hacky)
			game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").Jump = true
			task.wait(0.00001)
			humanoidRootPart.Velocity = Vector3.new(0,0,0)
			wait(1) -- 1 second cool down
			debounce = false

		end

	end


end
game.Players.LocalPlayer:GetMouse().KeyDown:Connect(onKeyPress) -- on key press

-- Script for adding a button to the screen
local function MobileGUI()	
	-- Create a ScreenGui
	local screenGui = Instance.new("ScreenGui")
	screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")

	local button = Instance.new("ImageButton")
	local corner = Instance.new("UICorner")
	button.Size = UDim2.new(0, 50, 0, 50)
	button.Position = UDim2.new(1, -180,1, -80)
	button.Image = "http://www.roblox.com/asset/?id=15427166971"
	button.Parent = screenGui
	button.BackgroundColor3 = Color3.new(1, 1, 1)
	corner.Parent = button
	corner.CornerRadius = UDim.new(0.5, 0)


	-- Connect a function to the button's 'Activated' event
	button.Activated:Connect(function()
		onKeyPress("q")
	end)
end

local function detectMobile(plyr)
	local isMobile = UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled
	if isMobile then
		MobileGUI()
	end
end

detectMobile(game.Players.LocalPlayer)

2 Likes

I never stated that my dash did not work.

To further clarify: My dash works, but when I go over a large hole, or any hole, ravine what ever, my character just floats in the air with no specific target to follow. How can I make it so the slide “sticks” to any surface. Do for example my character rotate towards the slope. Check the images on the original post to further explain

I still need help, lol how do I offset the hrp :sob:

Sorry if I misunderstood again but is this what you want? I changed the gravity very during the dash high so they ‘Stick’ to whatever they are on, if you want them to slide on their back then thats a matter of animation.

local debounce = false
local UserInputService = game:GetService("UserInputService")

local function onKeyPress(input)
	if input == "q" then
		if debounce == false then
			debounce = true
			local humanoidRootPart = game.Players.LocalPlayer.Character.HumanoidRootPart
			local humanoid = game.Players.LocalPlayer.Character.Humanoid
			local anim = Instance.new("Animation")
			anim.AnimationId = "rbxassetid://18237726269"

			--Animate

			local playerAnims = humanoid.Animator:GetPlayingAnimationTracks() -- gets all Animations

			for _,animation in playerAnims do -- Iterates through all Animations
				print(animation)
				animation:Stop() -- stops animations
			end

			game.Players.LocalPlayer.Character["Animate"].Enabled = false



			local animationTrack = humanoid:LoadAnimation(anim)

			wait(0.01)
			
			workspace.Gravity = 90000

			animationTrack:Play()

			local DashParticle = Instance.new("ParticleEmitter")
			DashParticle.Texture = "rbxassetid://14197943648"
			DashParticle.Parent = game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
			DashParticle.EmissionDirection = "Back"
			DashParticle.Lifetime = NumberRange.new(0.5,1)
			DashParticle.Rate = 90
			DashParticle.Orientation = Enum.ParticleOrientation.VelocityParallel
			DashParticle.Speed = NumberRange.new(3)
			DashParticle.Squash = NumberSequence.new(-1.5)

			for i = 0,10,1 do -- move the player forward
				task.wait(0.00001)
				local currentCFrame = humanoidRootPart:GetPivot()
				local forwardVector = currentCFrame.LookVector * 2
				local targetCFrame = currentCFrame + forwardVector
				humanoidRootPart:PivotTo(targetCFrame)
			end

			DashParticle.Enabled = false

			wait(0.5)
			workspace.Gravity = 196.2
			game.Players.LocalPlayer.Character["Animate"].Enabled = true
			wait(0.01)

			--Re-Enable Movement (Kind of hacky)
			game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").Jump = true
			task.wait(0.00001)
			humanoidRootPart.Velocity = Vector3.new(0,0,0)
			wait(1) -- 1 second cool down
			debounce = false

		end

	end


end
game.Players.LocalPlayer:GetMouse().KeyDown:Connect(onKeyPress) -- on key press

-- Script for adding a button to the screen
local function MobileGUI()	
	-- Create a ScreenGui
	local screenGui = Instance.new("ScreenGui")
	screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")

	local button = Instance.new("ImageButton")
	local corner = Instance.new("UICorner")
	button.Size = UDim2.new(0, 50, 0, 50)
	button.Position = UDim2.new(1, -180,1, -80)
	button.Image = "http://www.roblox.com/asset/?id=15427166971"
	button.Parent = screenGui
	button.BackgroundColor3 = Color3.new(1, 1, 1)
	corner.Parent = button
	corner.CornerRadius = UDim.new(0.5, 0)


	-- Connect a function to the button's 'Activated' event
	button.Activated:Connect(function()
		onKeyPress("q")
	end)
end

local function detectMobile(plyr)
	local isMobile = UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled
	if isMobile then
		MobileGUI()
	end
end

detectMobile(game.Players.LocalPlayer)

Update! Hopefully this is what you meant!

local debounce = false
local UserInputService = game:GetService("UserInputService")

local function onKeyPress(input)
	if input == "q" then
		if debounce == false then
			debounce = true
			local humanoidRootPart = game.Players.LocalPlayer.Character.HumanoidRootPart
			local humanoid = game.Players.LocalPlayer.Character.Humanoid
			local anim = Instance.new("Animation")
			anim.AnimationId = "rbxassetid://18249321324"

			--Animate

			local playerAnims = humanoid.Animator:GetPlayingAnimationTracks() -- gets all Animations

			for _,animation in playerAnims do -- Iterates through all Animations
				print(animation)
				animation:Stop() -- stops animations
			end

			game.Players.LocalPlayer.Character["Animate"].Enabled = false



			local animationTrack = humanoid:LoadAnimation(anim)

			wait(0.01)
			
			workspace.Gravity = 20000

			animationTrack:Play()

			local DashParticle = Instance.new("ParticleEmitter")
			DashParticle.Texture = "rbxassetid://14197943648"
			DashParticle.Parent = game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
			DashParticle.EmissionDirection = "Back"
			DashParticle.Lifetime = NumberRange.new(0.5,1)
			DashParticle.Rate = 90
			DashParticle.Orientation = Enum.ParticleOrientation.VelocityParallel
			DashParticle.Speed = NumberRange.new(3)
			DashParticle.Squash = NumberSequence.new(-1.5)

			for i = 0,10,1 do -- move the player forward
				task.wait(0.00001)
				local currentCFrame = humanoidRootPart:GetPivot()
				local forwardVector = currentCFrame.LookVector * 2
				local targetCFrame = currentCFrame + forwardVector
				humanoidRootPart:PivotTo(targetCFrame)
			end

			DashParticle.Enabled = false

			wait(0.5)
			workspace.Gravity = 196.2
			game.Players.LocalPlayer.Character["Animate"].Enabled = true
			wait(0.01)

			--Re-Enable Movement (Kind of hacky)
			game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").Jump = true
			task.wait(0.01)
			humanoidRootPart.Velocity = Vector3.new(0,0,0)
			wait(1) -- 1 second cool down
			debounce = false

		end

	end


end
game.Players.LocalPlayer:GetMouse().KeyDown:Connect(onKeyPress) -- on key press

-- Script for adding a button to the screen
local function MobileGUI()	
	-- Create a ScreenGui
	local screenGui = Instance.new("ScreenGui")
	screenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")

	local button = Instance.new("ImageButton")
	local corner = Instance.new("UICorner")
	button.Size = UDim2.new(0, 50, 0, 50)
	button.Position = UDim2.new(1, -180,1, -80)
	button.Image = "http://www.roblox.com/asset/?id=15427166971"
	button.Parent = screenGui
	button.BackgroundColor3 = Color3.new(1, 1, 1)
	corner.Parent = button
	corner.CornerRadius = UDim.new(0.5, 0)


	-- Connect a function to the button's 'Activated' event
	button.Activated:Connect(function()
		onKeyPress("q")
	end)
end

local function detectMobile(plyr)
	local isMobile = UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled
	if isMobile then
		MobileGUI()
	end
end

detectMobile(game.Players.LocalPlayer)
1 Like

Oh dang, i didnt know just simply changing the fking gravity would work so easily, i planned to learn whole trigonometry and shi. Thanks bro. Spent the whole day searching and scouting the whole internet for a solution

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.