remove this one at beginning (30 latters pls)
iâll edit the script later since iâm playing, wait here
btw read some APIs about the spawn function in the developer hub to understand it more and CFrames.
have you found an answer yet? i canât really help you if you donât learn from stuff and not just examples of what i written.
what I was thinking of, is running a function every frame that sets the lookvector again until the animation is ended
Anyways, you should create a while loop via spawn(function() so it doesnât interrupt the next code lines, make the humanoid root part move position in the Z axis based on itâs front perspective.
You donât have to add a code line where the humanoid root part faces a specific part, it just makes some signs that the script totally works, when doing the while loop, it should only operate when a variable like âcanStopâ is set to true, when you want it to end, you can set the âcanStopâ to false, make sure you create the variable when the player clicks, not before the tool activated has began so it wonât cause some bugs.
I made the sliding work on m1, but itâs not working on m2.
local Player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local character =Player.Character or Player.CharacterAdded:wait()
local Cooldown = Instance.new("BoolValue", game.Players.LocalPlayer)
Cooldown.Value = false
local Humanoid = character:WaitForChild("Humanoid")
local animator = Humanoid:FindFirstChildOfClass("Animator")
local Mouse = Player:GetMouse()
local m1 = Instance.new("Animation")
local Debounce = false
local BV
local BV2
local DebounceTimer = 6
m1.AnimationId = "rbxassetid://5945839988"
local m2 = Instance.new("Animation")
m2.AnimationId = "rbxassetid://5949219966"
local animationTrack = animator:LoadAnimation(m2)
local lolanimation = animator:LoadAnimation(m1)
local canMove
local model = character.HumanoidRootPart
local speed = 0.25
local function thread()
if canMove == true then
repeat
BV.MaxForce = Vector3.new(1,1,1) * math.huge
BV.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector * 13
wait()
game:GetService("RunService").Heartbeat:Wait()
until canMove == false
end
end
local tool = script.Parent.Parent.DemonFlip
local mouse = Player:GetMouse()
mouse.Button1Down:Connect(function()
if character:FindFirstChild("DemonFlip") and Cooldown.Value == false then
Cooldown.Value = true
BV = Instance.new("BodyVelocity", character.HumanoidRootPart)
local sound = Instance.new("Sound", game.Players.LocalPlayer)
sound.SoundId = "rbxassetid://5355789788"
Humanoid.WalkSpeed = 0
sound:Play()
lolanimation:Play()
canMove = true
spawn(thread)
lolanimation.Stopped:wait()
Humanoid.WalkSpeed = 16
canMove = false
sound:Destroy()
BV:Destroy()
BV = nil
end
end)
mouse.Button2Down:Connect(function()
if character:FindFirstChild("DemonFlip") and Cooldown.Value == false then
Cooldown.Value = true
BV = Instance.new("BodyVelocity", character.HumanoidRootPart)
local sound = Instance.new("Sound", game.Players.LocalPlayer)
sound.SoundId = "rbxassetid://5355789788"
local runtrack = Humanoid:LoadAnimation(m2)
sound:Play()
animationTrack:AdjustSpeed(1.5)
animationTrack:Play()
animationTrack:AdjustSpeed(1.5)
Humanoid.WalkSpeed = 0
spawn(thread)
animationTrack.Stopped:wait()
canMove = false
BV:Destroy()
BV = nil
animationTrack:AdjustSpeed(1)
Humanoid.WalkSpeed = 16
sound:Destroy()
end
end)
Cooldown.Changed:Connect(function()
if Cooldown.Value == true then
wait(5)
Cooldown.Value = false
end
end)
Set the bodyvelocityâs velocity to HRP.CFrame.LookVector * Speed every frame by using RunService.RenderStepped, then disconnect the renderstepped when you destroy the bodyvelocity.
It works for the m1, is what im saying, but the m2 doesnât work.
Just found out I did not send canMove to true on mousebutton2, heres the full script if anyone wants to make a move like this.
local Player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local character =Player.Character or Player.CharacterAdded:wait()
local Cooldown = Instance.new("BoolValue", game.Players.LocalPlayer)
Cooldown.Value = false
local Humanoid = character:WaitForChild("Humanoid")
local animator = Humanoid:FindFirstChildOfClass("Animator")
local Mouse = Player:GetMouse()
local m1 = Instance.new("Animation")
local Debounce = false
local BV
local BV2
local DebounceTimer = 6
m1.AnimationId = "rbxassetid://5945839988"
local m2 = Instance.new("Animation")
m2.AnimationId = "rbxassetid://5949219966"
local animationTrack = animator:LoadAnimation(m2)
local lolanimation = animator:LoadAnimation(m1)
local canMove
local model = character.HumanoidRootPart
local speed = 0.25
local function thread1()
if canMove == true then
repeat
BV2.MaxForce = Vector3.new(1,1,1) * math.huge
BV2.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector * 16
wait()
game:GetService("RunService").Heartbeat:Wait()
until canMove == false
end
end
local function thread()
if canMove == true then
repeat
BV.MaxForce = Vector3.new(1,1,1) * math.huge
BV.Velocity = Player.Character.HumanoidRootPart.CFrame.LookVector * 13
wait()
game:GetService("RunService").Heartbeat:Wait()
until canMove == false
end
end
local tool = script.Parent.Parent.DemonFlip
local mouse = Player:GetMouse()
mouse.Button1Down:Connect(function()
if character:FindFirstChild("DemonFlip") and Cooldown.Value == false then
Cooldown.Value = true
BV = Instance.new("BodyVelocity", character.HumanoidRootPart)
local sound = Instance.new("Sound", game.Players.LocalPlayer)
sound.SoundId = "rbxassetid://5355789788"
Humanoid.WalkSpeed = 0
sound:Play()
lolanimation:Play()
canMove = true
spawn(thread)
lolanimation.Stopped:wait()
Humanoid.WalkSpeed = 16
canMove = false
sound:Destroy()
BV:Destroy()
BV = nil
end
end)
mouse.Button2Down:Connect(function()
if character:FindFirstChild("DemonFlip") and Cooldown.Value == false then
Cooldown.Value = true
BV2 = Instance.new("BodyVelocity", character.HumanoidRootPart)
local sound = Instance.new("Sound", game.Players.LocalPlayer)
sound.SoundId = "rbxassetid://5355789788"
local runtrack = Humanoid:LoadAnimation(m2)
sound:Play()
animationTrack:AdjustSpeed(1.5)
animationTrack:Play()
animationTrack:AdjustSpeed(1.5)
Humanoid.WalkSpeed = 0
canMove = true
spawn(thread1)
animationTrack.Stopped:wait()
canMove = false
BV2:Destroy()
BV2 = nil
animationTrack:AdjustSpeed(1)
Humanoid.WalkSpeed = 16
sound:Destroy()
end
end)
Cooldown.Changed:Connect(function()
if Cooldown.Value == true then
wait(5)
Cooldown.Value = false
end
end)
Well you need to optimize your script, there are a lot of incoming bugs and itâs not going to be easy to do unless you got the basics.
I also let you alone to do the coding so you could learn from yourself and not just ask someone to help you like every single time you have an issue.
local Speed = 1.5
local Cooldown = 2
local Tool = script.Parent
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local M1Anim = Instance.new("Animation")
M1Anim.AnimationId = "rbxassetid://5945839988"
local Character = nil
local CurrentBV1 = nil
coroutine.wrap(function()
game:GetService("RunService").RenderStepped:Connect(function()
if Character ~= nil then
if CurrentBV1 ~= nil then
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart ~= nil then
CurrentBV1.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
CurrentBV1.Velocity = (HumanoidRootPart.Velocity + (Speed * HumanoidRootPart.CFrame.lookVector))
end
end
end
end)
end)()
local CDDBG = true
--Tool.Activated:Connect(function()
Mouse.Button1Down:Connect(function()
if CDDBG then CDDBG = false else return end
if Character ~= nil then
local Humanoid = Character:FindFirstChild("Humanoid")
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart ~= nil and Humanoid ~= nil then
CurrentBV1 = Instance.new("BodyVelocity", HumanoidRootPart)
CurrentBV1.Name = "M1BV"
local Sound = Instance.new("Sound", Tool)
Sound.SoundId = "rbxassetid://5355789788"
Sound.Volume = 2
if not Sound.IsLoaded then
Sound.Loaded:Wait()
end
Sound.Ended:Connect(function()
Sound:Destroy()
end)
Sound:Play()
local AnimTrack = Humanoid:LoadAnimation(M1Anim)
AnimTrack:Play()
AnimTrack.Stopped:Wait()
end
wait(1.25)
CurrentBV1:Destroy()
end
wait(Cooldown)
CDDBG = true
end)
--end)
Tool.Equipped:Connect(function()
Character = Tool.Parent
end)
Tool.Unequipped:Connect(function()
Character = nil
if CurrentBV1 ~= nil then
CurrentBV1:Destroy()
end
end)