Mobile Shiftlock

For mobile shiftlock, you can either fork the module to give yourself the ability of toggling shiftlock, or you can use GameSettings, like this

Also need to set the offset

2 Likes

im gonna bookmark this actually, i didnt know it was that easy

3 Likes

I assume that is a local script, and could you send the complete code for mobile?

Same bruh :sad:

30chssssssssssss

That is the complete code, just missing the part where you get the humanoid. What I have left out is stuff specific to my game

And it is a local script

im working on it right now, do you want the shiftlock always active or toggled by a button?

first, we are gonna want to enter the “CameraModule” module script and scroll on down to line 521, we are going to to select the end of that line and press enter to create a new line, then we can input the following code:

self.activeCameraController:SetIsMouseLocked(game.Players.LocalPlayer.shiftlock.Value)

next, we are going to create a local script called “mobileShiftlock” and put it in the “StarterPlayerScripts” folder under the “StarterPlayer” folder. inside this script, paste the following code:

local players = game:GetService("Players")

local shiftlock = Instance.new("BoolValue")

players.PlayerAdded:Connect(function(player)
	shiftlock.Parent = player
	shiftlock.Name = "shiftlock"
end)

if you want the shiftlock to be constant amongst the mobile players, type this underneath the previous code block:

local userInputService = game:GetService("UserInputService")

if userInputService.TouchEnabled then
	shiftlock.Value = true
end

however if you want this to be toggled by a button, create a “ScreenGui” instance underneath the “StarterGui” folder, and then make either a “TextButton” or “ImageButton” (up to your preference) under the “ScreenGui” and create a local script underneath your button. inside this button input this script:

local players = game:GetService("Players")
local userInputService = game:GetService("UserInputService")

local shiftlock = players.LocalPlayer.shiftlock

if userInputService.TouchEnabled then
	script.Parent.Visible = true
else 
	script.Parent.Visible = false	
end

script.Parent.MouseButton1Click:Connect(function()
	shiftlock.Value = not shiftlock.Value
end)

feel free to polish up any of the code formatting as i tried to make this as easy as possible to implement, rather than make it visually appealing

i dont have too much time on my hands so i cant fact check these scripts, so if anything breaks please follow up with the given errors!

1 Like

im heading to bed so ill check in on any replies in the morning, goodnight!

Just now saw this… I will give it a try

1 Like

What is “MouseLock” meant to be set to? A button?

2 Likes

Got it to work. Thank you both, @thermostat_guy and @Tomi1231.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.