I’m working on a platform fighter, and I’ve made a script that tweens the player turning left and right instead of it immediately looking either direction, the problem is that the player can’t move while being tweened, any way to fix this?
local players = game.Players
local player = players.LocalPlayer
local character = player.Character
local root = character.HumanoidRootPart
local camera = workspace.CurrentCamera
local UserInputService = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
local keyA = false
local keyD = false
game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode.D then
keyD = true
keyA = false
elseif inputObject.KeyCode == Enum.KeyCode.A then
keyA = true
keyD = false
end
end)
spawn(function()
while true do wait ()
if keyA == true and keyD == false then
local Tween = TS:Create(root, TweenInfo.new(.5), {CFrame = CFrame.new(root.Position, root.Position - camera.CFrame.RightVector)}):Play()
keyA = false
elseif keyA == false and keyD == true then
local Tween = TS:Create(root, TweenInfo.new(.5), {CFrame = CFrame.new(root.Position, root.Position + camera.CFrame.RightVector)}):Play()
keyD = false
end
end
end)