How can i revert back to the Normal Controls From Side Scrolling Controls

Ok, so am currently working on a game in which when the player is in the lobby the player is having the Normal 3D camera and the normal controls just like all the other roblox games. On the other hand when the player joins a level / stage in my game the player camera changes to like 2D or side scrolling as well as the controls they can only Move with the A and D key and space to jump.

Here’s the problem -: When the player comes back to the lobby like for example they completed the level and want to come back to the lobby, they came back and they should get the normal 3D camera and controls back. I’m done with the Normal camera and it works completely normal like the default camera but i’m not sure that how can i revert back to the Normal 3D Controls.

I tried making many script they din’t work and i also searched the whole forum and i couldn’t find a possible solution. So with no choice left i’m creating this post and hoping some someone could help me :frowning:

if your still confused and don’t know what am i talking about here are some screenshots.

When The player is in the lobby.

When the player is in a level.

please someone help me i have been trying to find a solution for a over a week now. :frowning:

1 Like

set camera mode back to classic if it isn’t already and set camera subject to humanoid(I will make a code for you real quick below if you don’t already know how to do it)

i did say the camera is completely fine the problem is the Normal Controls The WASD is the problem i just want the control script.

oh okay , I didn’t saw oopsies

when the player is in 2D only the A and D key work cause 2D and when they go back to 3D i want the 3D controls back i managed to get back the camera doe.

I don’t really know your code but you did made the player only press a and d and space so if you know how to do that you should just do that but with the normal controls.

i din’t lol i just went to the developer hub and yoinked the 2D controls. im not good with 2D stuff.

well sorry I can’t really help much because I never done a 2D platformer and I can’t do much if there isn’t that much information about the code

game.ReplicatedStorage.RemoteEvents.ChangeControls.OnClientEvent:Connect(function()
local player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")

local jumping = false
local leftValue, rightValue = 0, 0

local function onLeft(actionName, inputState)
	if inputState == Enum.UserInputState.Begin then	
		leftValue = 1
	elseif inputState == Enum.UserInputState.End then
		leftValue = 0
	end
end

local function onRight(actionName, inputState)
	if inputState == Enum.UserInputState.Begin then
		rightValue = 1
	elseif inputState == Enum.UserInputState.End then
		rightValue = 0
	end
end

local function onJump(actionName, inputState)
	if inputState == Enum.UserInputState.Begin then
		jumping = true
	elseif inputState == Enum.UserInputState.End then
		jumping = false
	end
end

local function onUpdate()
	if player.Character and player.Character:FindFirstChild("Humanoid") then
		if jumping then
			player.Character.Humanoid.Jump = true
		end
		local moveDirection = rightValue - leftValue
		player.Character.Humanoid:Move(Vector3.new(moveDirection,0,0), false)
	end
end

RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, onUpdate)
ContextActionService:BindAction("Left", onLeft, true, "a", Enum.KeyCode.Left, Enum.KeyCode.DPadLeft)
ContextActionService:BindAction("Right", onRight, true, "d", Enum.KeyCode.Right, Enum.KeyCode.DPadRight)
ContextActionService:BindAction("Jump", onJump, true , Enum.KeyCode.Space, Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)
end)

here’s the code please trying to help this is the 2D controls. code.

I’m searching up for the normal control script and you could use it to revert it back.

sorry It kinda late for me now but if you still have this problem by tommorow I will help you tommorow but try to search up for normal player control script or something like that.

thank you for the help i’ve been trying since a week. <3

1 Like

it’s fine i’ll message you if i could not do it.

Looking at your code, I think you would just use the RunService:UnbindToRenderStep(“Control”) and ContextActionService:UnbindAllActions() functions to revert to default controls.

so can i just write

RunService:UnbindToRenderStep(“Control”)

to unbind all the 2d Controls??

I’m currently working on a game similar to yours and wow! Your levels and map are way better. I was going to make a map similar to the New Super Mario Bros. Wii map. That map wouldn’t need to revert to 3D controls because it’s 2.5D.

but my game is diffrent i NEED to go back to the 3D Controls :frowning:

i tried it but it did not work.

Well, not entirely. Your script runs when the server fires the game.ReplicatedStorage.RemoteEvents.ChangeControls event for the player. You would need another remote event, or rewrite your code as a toggle function to change back to the standard controls.

It would probably be easiest to make a new event in the RemoteEvents folder, call it say ResetControls, and then do something like:

game.ReplicatedStorage.RemoteEvents.ResetControls.OnClientEvent:Connect(function()
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")

RunService:UnbindToRenderStep("Control")
ContextActionService:UnbindAllActions()

end)

Then you would need to fire the ResetControls event from a server side script in order to run the above code.

1 Like

Got it working thank you so much!