Help with making a slide mechanic

I’m trying to make it so if the player presses a button they perform a slide move but I can’t figure out how to approach this problem, I tried adding in a BodyGyro to the player which quickly ends as soon as it starts but I couldn’t figure out how to do that so what do I do to build this mechanic?

2 Likes

Assuming you already have knowledge on Remote Events and UserInputService, you could use a BodyVelocity to launch the player slightly.

local Move2 = Instance.new("BodyVelocity")
	Move2.MaxForce = Vector3.new(8000,8000,8000)--Power
	Move2.Velocity = char.HumanoidRootPart.CFrame.lookVector*100--Direction
Move2.Parent = char.UpperTorso
If not, here is a full Example:

UserInputService/Local Script:

local UIS = game:GetService("UserInputService")
local Event = game:GetService("ReplicatedStorage").RemoteEvent

UIS.InputBegan:Connect(function(inputmethod, typing)
	if not typing then
		if inputmethod.KeyCode == Enum.KeyCode.Z then
			Event:FireServer("Slide", true)
		end
	end
end)

Server Script:

local Event = game:GetService("ReplicatedStorage").RemoteEvent

    Event.OnServerEvent:Connect(function(player, Request)
    	if Request == "Slide" then
    		local Move2 = Instance.new("BodyVelocity")
    			Move2.MaxForce = Vector3.new(8000,8000,8000)--Power
    		        Move2.Velocity = player.Character.HumanoidRootPart.CFrame.lookVector*100--Direction
    		Move2.Parent = player.Character.UpperTorso
		wait(.25)
	    Move2:Destroy()
    end
end)
12 Likes

Excuse me for asking but where do all the scripts go into their sections like starter player or replicated storage etc.

Put the local script in starterplayerscripts, or even StarterGui.
Create a RemoteEvent and put it into ReplicatedStorage, and place the Server Script in ServerScriptService

1 Like

Question, where’s the remote event since there’s 3 scripts that need to go into 3 different places but I only have 2 scripts and the scripts you’ve shown me only go into 2 sections.

Screenshot_65

3 Likes