How To Make Touch Screen/Mobile Device Screen Shift Lock Button/How to Enable Shift lock while Clicking With Different Buttons

This is an exact topic that was locked and unlisted a couple of hours ago, or maybe yesterday.

I wouldn’t do it again, but it’s nice that you made a resource/tutorial on how to make shift lock on mobile.

Post right here.

3 Likes

Yes It was Unlisted Due to some one flagging it thinking it was duplicated even thou it is the same Topic but One is on Mobile and the other is on Computer. I have added the Computer part to the Bottom of this one. Also I was looking for this for a while but when I look through the scripts that Roblox Made I new I had found it.

I just want to say thanks again for viewing this I spent a 5+ hours going through the modules. I got the Idea of adding shift lock ability a little bit ago while playing a game on controller the Game was called Dungeon Quest by @vCaffy . I would like to thank @itsyourdriver, @grif_0, @activefrenzy, @painted_fence,@loueque, @vCaffy for Viewing, Liking and possibly adding this feature to there game Some of these tutorials take a while and It is nice to see people appreciating the things I do. Also Special thanks to every who has viewed my tutorials/articles and also if they liked it.

8 Likes

It makes no sense why Roblox didn’t just implement this as an optional feature using BindAction. BindAction allows you to create your own button for mobile using Roblox’s default mobile UIs while also supporting PC and Console players.

6 Likes

I am actually going to implement this feature in my game’s next update. For literally years, (I’m not kidding) I’ve looked for a way to implement shift lock on mobile and other devices, and this is the first method that has actually worked. All the other tutorials were either too complicated to understand, were obfuscated, or used deprecated or otherwise obsolete features that no longer worked. Again, this is the first and only method I’ve used that has actually worked. Thank you so much for this tutorial! I’m primarily an iPad user (at least when I’m not using Studio) so the fact that shift lock is implement-able (is that even a word) is just amazing. Thanks again!

I’ve also seen your other helpful tutorials. I don’t follow people very often (I think I follow less than 20 people) but I just followed you.

6 Likes

If this thread ever goes out of date please let me know here so I can look for a way to update it!

1 Like

CameraModule:Update(dt) is now on line 521 instead of 468

1 Like

You can make a video tutorial going in-depth to this tutorial @Alvin_Blox @UseCode_Tap I give all of you permission. It will be useful for people to know. and it will be helpful to the community to make their games support mobile shift lock!

1 Like

I don’t know if I am missing something but I can’t find this in studio.

Edit: I mean where “Starter Script Services” is, sorry I don’t script.

2 Likes

Thanks For telling me it was just a word mistake here is where I meant. image

2 Likes

Hello thanks for the tutorial!
I might be doing this wrong but the part when I put the self.activeCameraController:SetIsMouseLocked(script.Parent.Parent.Parent.isShiftlock.Value)
in the CameraModule the shiflock stops working, you can enable it but then your camera is no longer forced and you can move freely, it was working fine the first time but now everytime works like I tell you, you know why?
It works on console and mobile but it seems to break the shiftlock at PC

2 Likes

I’ve had that issue. All you have to do is embed that code in an if statement like this:

if UserInputService.TouchEnabled then
     - code
end
3 Likes

Tsym for the reply! It works! :smiley:

2 Likes

If Your Reading This And You Don’t Understand Something Just Write it here I will be happy to explain just reply and I or someone else may respond. If I have made a typo or something also reply to tell me!
Thanks!

2 Likes
Should Roblox Add A Mobile Shiftlock Function
  • Yes
  • No

0 voters

1 Like

How would I make it have the camera offset that the PC shiftlock has?

What do you mean by offset like PC?


There’s a slight offset to the left on the camera when shift lock is enabled on PC, is this not enabled with the tutorial? (Haven’t checked)

1 Like

Is there a way to make the Gui only show on Mobile, on PC it turns shiftlock on, but after that it breaks the mouse, which is fair because its designed for mobile!

Thanks for the tutorial!! :smiley:

Here is a small tutorial for cross-platform use, for restricting the user the same way as computer users with DevEnableMouseLock and add a camera offset:

In order to utilize this without breaking computer’s own shift lock, (cross-platform use), you need to check if UserInputService.TouchEnabled is true before setting mouse lock. I’d also recommend using .Changed instead of constantly firing the SetIsMouseLocked function, and check DevEnableMouseLock before firing, which is useful for restricting players. Here is an example of how that would look:

script.Parent.Parent.Parent.isShiftlock.Changed:Connect(function(value) -- When "isShiftlock" value changes, fires function with a "value" parameter
	if UserInputService.TouchEnabled and Players.LocalPlayer.DevEnableMouseLock then -- If DevEnablesMouseLock and TouchEnabled, then
		self.activeCameraController:SetIsMouseLocked(value) -- Set Mouse Lock based on value parameter
	end
end)

This can also be used to hide the UI from computer users and only let mobile users utilize it. To do this, simply clone the UI to the PlayerGui if TouchEnabled is true, or destroy the UI if TouchEnabled is false.

If you’re fond of Shiftlock’s camera offset, you can quite easily add that into the script by checking if the value is true and then adding or removing into Humanoid.CameraOffset. Here is the code:

script.Parent.Parent.Parent.isShiftlock.Changed:Connect(function(value) -- When "isShiftlock" value changes, fires function with a "value" parameter
	if UserInputService.TouchEnabled and Players.LocalPlayer.DevEnableMouseLock then -- If DevEnablesMouseLock and TouchEnabled, then
		self.activeCameraController:SetIsMouseLocked(value) -- Set Mouse Lock based on value parameter
		local Humanoid = Players.LocalPlayer.Character:FindFirstChild("Humanoid") -- Variable Humanoid is defined as the player's humanoid.
		Humanoid.CameraOffset = Vector3.new(0,0,0) -- Humanoid.CameraOffset is reset.
		if value then -- If value is true then
			Humanoid.CameraOffset = Vector3.new(1.75,0,0) -- Humanoid.CameraOffset is equal to a new vector3 value of 1.75 studs in X.
		end
	end
end)

This should be the result:

Enjoy! :grin:

4 Likes