nice tutorial, do add guard clauses and for a complementary thing, you could perhaps just include those elements in the server storage (or well, replicatedstorage i guess depending on where you want latency) and copy them to your humanoidrootpart, in order to avoid setting the options again and again
local uis = game:GetService("UserInputService") local RS = game:GetService("ReplicatedStorage") local player = game:GetService("Players").LocalPlayer local char = player.Character or player.CharacterAdded:Wait() local hum = char:WaitForChild("Humanoid") local Root = char:WaitForChild("HumanoidRootPart") local StaminaManager = require(game.ReplicatedStorage.StmHandlerFolder.StaminaManager) local canRoll = true local maxStamina = 100 local cam = game.Workspace:WaitForChild("Camera") local rollDepletionAmount = 30 local function rollMotion(direction, animtrack) animtrack:Play() --play animation script.DashSound:Play() local BV = Instance.new("BodyVelocity") BV.MaxForce = Vector3.new(30000, 0, 30000) BV.Parent = Root local canLoop = true
task.spawn(function() task.wait(0.18) --animation length canLoop = false end) while true do if canLoop == false then break end
local c1 = Vector3.new(cam.CFrame.X, Root.CFrame.Y, cam.CFrame.Z) local c2 = cam.CFrame * CFrame.new(0, 0, 2) local c3 = Vector3.new(c2.X, char.HumanoidRootPart.CFrame.Y, c2.Z) local DD = CFrame.new(c1, c3)*CFrame.Angles(0, math.rad(direction), 0) BV.Velocity = DD.lookVector * 60 --change number for higher speed
task.wait(0.04) --CFrame update speed end BV:Destroy() end uis.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.Q then local stamina = StaminaManager.getStamina() --check if: character loaded, player has enough stamina, debounce, player is moving if char and Root and stamina >= rollDepletionAmount and canRoll == true and hum.MoveDirection.Magnitude > 0 then canRoll = false StaminaManager.updateStamina(-rollDepletionAmount, player) --subtract stamina --check if player uses ShiftLock if uis.MouseBehavior == Enum.MouseBehavior.LockCenter then if uis:IsKeyDown(Enum.KeyCode.W) then --dash forward local direction = -180 local animtrack = hum.Animator:LoadAnimation(script.FrontDash) rollMotion(direction, animtrack) elseif uis:IsKeyDown(Enum.KeyCode.S) then --dash backwards local direction = 0 local animtrack = hum.Animator:LoadAnimation(script.BackDash) rollMotion(direction, animtrack) elseif uis:IsKeyDown(Enum.KeyCode.A) then --dash to the left local direction = -90 local animtrack = hum.Animator:LoadAnimation(script.LeftDash) rollMotion(direction, animtrack) elseif uis:IsKeyDown(Enum.KeyCode.D) then --dash to the right local direction = 90 local animtrack = hum.Animator:LoadAnimation(script.RightDash) rollMotion(direction, animtrack) end else --if ShiftLock is off then do only front dash if uis:IsKeyDown(Enum.KeyCode.W) then local direction = -180 local animtrack = hum.Animator:LoadAnimation(script.FrontDash) rollMotion(direction, animtrack) elseif uis:IsKeyDown(Enum.KeyCode.S) then local direction = 0 local animtrack = hum.Animator:LoadAnimation(script.FrontDash) rollMotion(direction, animtrack) elseif uis:IsKeyDown(Enum.KeyCode.A) then local direction = -90 local animtrack = hum.Animator:LoadAnimation(script.FrontDash) rollMotion(direction, animtrack) elseif uis:IsKeyDown(Enum.KeyCode.D) then local direction = 90 local animtrack = hum.Animator:LoadAnimation(script.FrontDash) rollMotion(direction, animtrack) end end task.wait(1.5) --cooldown canRoll = true end end end)
nice tutorial, do add guard clauses and for a complementary thing, you could perhaps just include those elements in the server storage (or well, replicatedstorage i guess depending on where you want latency) and copy them to your humanoidrootpart, in order to avoid setting the options again and again
W vid
Make it in minutes. 30. Make it in half an hour.
Well after this video you should be able to make one yourself in minutes. Explaining the logic behind my code was a majority of the video
@@SolepsusYT oh ok
outdated but still works with some changes, ty
is it outdated? which part?
local uis = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local Root = char:WaitForChild("HumanoidRootPart")
local StaminaManager = require(game.ReplicatedStorage.StmHandlerFolder.StaminaManager)
local canRoll = true
local maxStamina = 100
local cam = game.Workspace:WaitForChild("Camera")
local rollDepletionAmount = 30
local function rollMotion(direction, animtrack)
animtrack:Play() --play animation
script.DashSound:Play()
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(30000, 0, 30000)
BV.Parent = Root
local canLoop = true
task.spawn(function()
task.wait(0.18) --animation length
canLoop = false
end)
while true do
if canLoop == false then break end
local c1 = Vector3.new(cam.CFrame.X, Root.CFrame.Y, cam.CFrame.Z)
local c2 = cam.CFrame * CFrame.new(0, 0, 2)
local c3 = Vector3.new(c2.X, char.HumanoidRootPart.CFrame.Y, c2.Z)
local DD = CFrame.new(c1, c3)*CFrame.Angles(0, math.rad(direction), 0)
BV.Velocity = DD.lookVector * 60 --change number for higher speed
task.wait(0.04) --CFrame update speed
end
BV:Destroy()
end
uis.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Q then
local stamina = StaminaManager.getStamina()
--check if: character loaded, player has enough stamina, debounce, player is moving
if char and Root and stamina >= rollDepletionAmount and canRoll == true and hum.MoveDirection.Magnitude > 0 then
canRoll = false
StaminaManager.updateStamina(-rollDepletionAmount, player) --subtract stamina
--check if player uses ShiftLock
if uis.MouseBehavior == Enum.MouseBehavior.LockCenter then
if uis:IsKeyDown(Enum.KeyCode.W) then --dash forward
local direction = -180
local animtrack = hum.Animator:LoadAnimation(script.FrontDash)
rollMotion(direction, animtrack)
elseif uis:IsKeyDown(Enum.KeyCode.S) then --dash backwards
local direction = 0
local animtrack = hum.Animator:LoadAnimation(script.BackDash)
rollMotion(direction, animtrack)
elseif uis:IsKeyDown(Enum.KeyCode.A) then --dash to the left
local direction = -90
local animtrack = hum.Animator:LoadAnimation(script.LeftDash)
rollMotion(direction, animtrack)
elseif uis:IsKeyDown(Enum.KeyCode.D) then --dash to the right
local direction = 90
local animtrack = hum.Animator:LoadAnimation(script.RightDash)
rollMotion(direction, animtrack)
end
else --if ShiftLock is off then do only front dash
if uis:IsKeyDown(Enum.KeyCode.W) then
local direction = -180
local animtrack = hum.Animator:LoadAnimation(script.FrontDash)
rollMotion(direction, animtrack)
elseif uis:IsKeyDown(Enum.KeyCode.S) then
local direction = 0
local animtrack = hum.Animator:LoadAnimation(script.FrontDash)
rollMotion(direction, animtrack)
elseif uis:IsKeyDown(Enum.KeyCode.A) then
local direction = -90
local animtrack = hum.Animator:LoadAnimation(script.FrontDash)
rollMotion(direction, animtrack)
elseif uis:IsKeyDown(Enum.KeyCode.D) then
local direction = 90
local animtrack = hum.Animator:LoadAnimation(script.FrontDash)
rollMotion(direction, animtrack)
end
end
task.wait(1.5) --cooldown
canRoll = true
end
end
end)
unnecessarily long, and something like stamina should probably not be locally stored