This is the basic layout, I’m not allowed to write full scripts on the DevForum as you need to learn too .
--dictionary and local userInput here.
userInput.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Space then
--put the for loop in here.
--Your tween.
end
end)
You helped me out in a much greater way then I could ever wish for.
Much obliged !
anyho I better change the title of this threat, because it doesn’t fit the answer.
I don’t think it has to do anything with that line as we are never specifying a instance. I think it’s your tween if you have made that yet. Here is a good way to make up the tween:
pretty sure i did everything correctly but error persists ant the exact same line
local TweenService = game:GetService("TweenService")
local cframeToGoTo = char.Torso.CFrame
TweenService:Create(char.HumanoidRootPart, TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false), {CFrame = cframeToGoTo})
for _,v in pairs(userInput:GetKeysPressed()) do
local keyCFrame = keyDir[userInput:GetStringForKeyCode(v)]
if keyCFrame then cframeToGoTo = cframeToGoTo * keyCFrame
end end end end)
From my understanig we are creating another root part that is welded to player and applay cframe force.
right ?
If this is your complete script your order is completely wrong, the tween should be at the bottom and where is the InputBegan event? Also you must specify char! local char = game.Players.LocalPlayer.Character.
We are not creating nor cloning a rootpart, I’ll explain the script:
Once space gets pressed (InputBegan) we create a variable called cframeToGoTo (local cframeToGoTo = char.HumanoidRootPart.CFrame), next we check loop through every key that is currently pressed and we check if it has a linked cframe (the dictionary). Next we multiply that with the cframeToGoTo variable, let’s say that the A and S keys are currently pressed, and the position of the HumanoidRootPart is exactly 0, 0, 0, we will add 10 studs on the X axis and 10 studs on the Z axis because the keys correspond to that cframe value on the dictionary, at the end we’d have: CFrame.new(10,0,10), next we create a tween which will smoothly move the HumanoidRootPart to our result cframe.
If the script above is your full script you are missing alot of things!
Well its not, i know about wariables and how to do them properly, this time i just posted “important parts of code” at least in my opinion.
and here is the final version
local char = game.Players.LocalPlayer.Character
local userInput = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local cframeToGoTo = char.Torso.CFrame
local humanoid = char:WaitForChild("Humanoid")
if not char then wait()end
userInput.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Space then
local keyDir =
{["S"] = CFrame.new(0,0,10),
["D"] = CFrame.new(-100,1,0),
["W"] = CFrame.new(0,0,-10),
["A"] = CFrame.new(10,0,0),}
for _,v in pairs(userInput:GetKeysPressed()) do
local keyCFrame = keyDir[userInput:GetStringForKeyCode(v)] -- this line
if keyCFrame then cframeToGoTo = cframeToGoTo * keyCFrame
end end end end)
TweenService:Create(char.HumanoidRootPart, TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false), {CFrame = cframeToGoTo})
there is one extra variable for later
but the problem still persists
I reused parts and I figured out what was wrong, after patching them it would do some weird movements if I used tweenService. That’s why I switched it to use the :MoveTo() function of the humanoid.
And I might upload it to roblox if I see a familiar topic.
The contextActionService’s use is to simply block player input.
I remember trying to do it in a similar way (much simpler way) but scraped the concept after figuring out that when the player is holding the button and then performs an action he would have to re-press the buttons to continue moving or in other words, the game would forget what inputs were sent before the action.
oh and i found out that it will soft lock player if there is something in the way
remowing humanoid.MoveToFinished:Wait() fixes it.
maybe i should add if is something in the way then wait()
I don’t understand you, first you say that it works like a dream and now it’s janky? That is quite rude to say if you keep in mind that I did this willingly…
I said it after longer use and a few experiments.
I really appreciate your help but as it turns out my thingy from the start runs smoother it was much more tiresome to write but as long as it works.
Just as a comparison
Yours with a few extra features and a bit of optimization
And my old somewhat finished script
My biggest issue with is that your script blocks all inputs for a moment and thos forgets that player is still holding movement buttons forcing player to re-press them constantly after every dodge making for an unpleasant experience.
As of now, I’m working on invincibility frames and on later date animation.
I’m sorry if you feel used by me but in the end, you suggested that alternative.