So basically, In the project I’m working in, since It’s a 2D game, I disabled forward and backwards movement, but I would still like for the player to rotate their character to the camera at least
So I tried doing this:
local CAS = game:GetService("ContextActionService")
local RS = game:GetService("RunService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local HRP = char:WaitForChild("HumanoidRootPart")
local MovementEvent = game:GetService("ReplicatedStorage").Events.SetMovement
local UIS = game:GetService("UserInputService")
local pressing_S = false
MovementEvent.OnClientEvent:Connect(function(action)
if action == "disable_SW" then
CAS:BindActionAtPriority("disableForwardMovement", function()
return Enum.ContextActionResult.Sink
end, false, Enum.ContextActionPriority.High.Value + 50, Enum.PlayerActions.CharacterForward)
CAS:BindActionAtPriority("disableBackwardMovement", function()
return Enum.ContextActionResult.Sink
end, false, Enum.ContextActionPriority.High.Value + 50, Enum.PlayerActions.CharacterBackward)
elseif action == "enable_SW" then
CAS:UnbindAction("disableForwardMovement")
CAS:UnbindAction("disableBackwardMovement")
end
end)
UIS.InputBegan:Connect(function(input, istyping)
if istyping then return end
if input.KeyCode == Enum.KeyCode.S then
if plr.Stats.isPlaying.Value == true then
pressing_S = true
end
end
end)
UIS.InputEnded:Connect(function(input, istyping)
if istyping then return end
if input.KeyCode == Enum.KeyCode.S then
print("wow")
pressing_S = false
end
end)
RS.Heartbeat:Connect(function()
if pressing_S == true then
print("yas")
HRP.CFrame = CFrame.lookAt(HRP.Position, Vector3.new(workspace.Map:FindFirstChild("CameraPoint").CFrame.X, HRP.Position.Y, workspace.Map:FindFirstChild("CameraPoint").CFrame.Z))
end
end)
That’s the disable movement script with the S input script
But S key input is never detected meanwhile backwards movement is disabled
What can I do in this situation?