Hello, I am completely new to Scripting, and the Forum if I did something wrong I am sorry, now I’ve just copied a Script from Youtube, because I don’t know anything yet, however I have some problems and I hope I get help here.
First thing is that the running animation dose not play when I run, I don’t have animations for the dashing yet but that shouldn’t stop the running animation, right?
Second thing is that I seem to slide a bit in a specific angle
I’ve tried some things (own changes in the code) but always put the original back, cuz my idea didn’t work, and I don’t know what I tried, I forgot it because I had to read this Forum to post my question
Did a Screen Recording but it was too big, so I hope that the script alone helps
The Scripts:
StaterPlayer → StaterPlayerScripts → MovementScript
local UIS = game:GetService("UserInputService")
local MovementEvent = game.ReplicatedStorage:WaitForChild("MovementEvent")
local Player = game.Players.LocalPlayer
local DashDirection = ""
UIS.InputBegan:Connect(function(Input, processed)
if Input.UserInputType == Enum.UserInputType.Keyboard and not processed then
if Input.KeyCode == Enum.KeyCode.LeftControl then
Player.Character.Humanoid.WalkSpeed = 30
elseif Input.KeyCode == Enum.KeyCode.W or Input.KeyCode == Enum.KeyCode.A or Input.KeyCode == Enum.KeyCode.S or Input.KeyCode == Enum.KeyCode.D then
DashDirection = Input.KeyCode.Name
elseif Input.KeyCode == Enum.KeyCode.C and Player.Character.IsRunning.Value == true then
MovementEvent:FireServer("Dash", DashDirection)
end
end
end)
UIS.InputEnded:Connect(function(Input, processed)
if Input.UserInputType == Enum.UserInputType.Keyboard and not processed then
if Input.KeyCode == Enum.KeyCode.LeftControl then
Player.Character.Humanoid.WalkSpeed = 12
end
end
end)
ServerScriptService → DashMovement-Server
local DS = game:GetService("Debris")
local SS = game:GetService("SoundService")
local MovementEvent = game.ReplicatedStorage:WaitForChild("MovementEvent")
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(Character)
local CanDash = Instance.new("BoolValue", Character)
CanDash.Name = "CanDash"
CanDash.Value = true
local IsRunning = Instance.new("BoolValue", Character)
IsRunning.Name = "IsRunning"
IsRunning.Value = false
Character.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=129355562064083"
Character.Animate.run.RunAnim.AnimationId = "http://www.roblox.com/asset/?id=99806970147725"
Character.Animate.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=77456603452990"
Character.Humanoid.Running:Connect(function(Speed)
if Speed > 13 then
Character.IsRunning.Value = true
else
Character.IsRunning.Value = false
end
end)
end)
end)
MovementEvent.OnServerEvent:Connect(function(plr, eventtype, Arg1)
local Character = plr.Character
if eventtype == "Dash" and Character.CanDash.Value == true then
Character.CanDash.Value = false
local BV = Instance.new("BodyVelocity", Character.HumanoidRootPart)
delay(2, function()
Character.CanDash.Value = true
end)
local DashDirection = Arg1
local Attachment = Instance.new("Attachment", Character.HumanoidRootPart)
local LinearVelocity = Instance.new("LinearVelocity", Attachment)
local Part = Instance.new("Part", workspace)
Part.Anchored = true
Part.Transparency = 1
Part.CanCollide = false
local Multiplyer
if DashDirection == "W" then
Multiplyer = CFrame.new(-1, -1, -20)
elseif DashDirection == "A" then
Multiplyer = CFrame.new(-20, -1, -1)
elseif DashDirection == "S" then
Multiplyer = CFrame.new(-1, -1, 20)
elseif DashDirection == "D" then
Multiplyer = CFrame.new(20, -1, -1)
end
local AT = Character.Humanoid.Animator:LoadAnimation(script[DashDirection.."DashAnimation"])
AT:Play()
SS.Dash:Play()
Part.CFrame = Character.HumanoidRootPart.CFrame * Multiplyer
LinearVelocity.MaxForce = 99999
LinearVelocity.VectorVelocity = (Part.Position - Character.HumanoidRootPart.Position).Unit * Vector3.new(100, 0, 100)
LinearVelocity.Attachment0 = Attachment
DS:AddItem(Attachment, 0.1)
end
end)