#Shiftlock on console

91 messages · Page 1 of 1 (latest)

brazen hill
#

So basically i have an issue, i made a shiftlock for console/controller players but when you want to do it on pc, you can't, everything doesn't works, look at the video for more details. It doesn't shows any error

#
local UserInputService = game:GetService("UserInputService");
local SelectedShiftLock = Enum.KeyCode.ButtonL2; -- here
local players = game:GetService("Players");
local player = players.LocalPlayer;

local enabled = false;
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
    local code = input.KeyCode;
    if(code == SelectedShiftLock)then
        if(enabled)then
            player:SetAttribute("MouseLockEnabled", true) 
        else
            player:SetAttribute("MouseLockEnabled", false) 
        end
        enabled = not enabled;
    end
end)```
This is my script + I have a module script for it
pliant cedar
#

Send the module script too if you can

brazen hill
pliant cedar
#

Were there that many?

brazen hill
pliant cedar
#

Yeah but i mean, inside of it should only be 2 more scripts if i dont bad remember

brazen hill
pliant cedar
#

ok i saw them lol

#

the problem is probably that the module script is overwritting the inner workings of Shiftlock

#
local UserInputService = game:GetService("UserInputService");
local SelectedShiftLock = Enum.KeyCode.ButtonY; -- here
local players = game:GetService("Players");
local player = players.LocalPlayer;

--Local script in StarterPlayerCharacter
--Services:
local RunService = game:GetService("RunService")
--Variables:
local char = player.CharacterAdded:Wait();
local hum = char:WaitForChild("Humanoid")
local root = hum.RootPart -- The HumanoidRootPart


--Toggle Function:
function shiftLock(active) --Toggle shift.lock function
    if active then        
        hum.CameraOffset = Vector3.new(1.75,0,0) -- I assume this is about the right camera offset.
        hum.AutoRotate = false --Disable the automatic rotation since we are the ones setting it.

        RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
            UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter --Set the mouse to center every frame.

            local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
            root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0,y,0) --Set the root part to the camera's rotation
        end) 
    else
        hum.AutoRotate = true --Let the humanoid handle the camera rotations again.
        hum.CameraOffset = Vector3.new(0,0,0) --Move the camera back to normal.
        RunService:UnbindFromRenderStep("ShiftLock") -- Allow mouse to move freely.
        UserInputService.MouseBehavior = Enum.MouseBehavior.Default -- Let the mouse move freely
    end
end

local enabled = false;
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
    local code = input.KeyCode;
    if(code == SelectedShiftLock)then
        if(enabled)then
            shiftLock(true)
        else
            shiftLock(false)
        end
        enabled = not enabled;
    end
end)
#

@brazen hill try this, is a different way of making it, you can delete the module script

brazen hill
#

Okay so for console it isn't working but for pc it works like before

pliant cedar
brazen hill
#

Yep I'm sure

#

I can send a video in proof

pliant cedar
#

take a look i placed ButtonY

#

maybe thats the reason

brazen hill
pliant cedar
#

Replace it by X and try

#

just for debugging

brazen hill
#

K

brazen hill
pliant cedar
#

let me grab my xbox controller

#

time to test

brazen hill
#

Maybe I re-add the module script?

#

ok module script breaks it

pliant cedar
#

It is working for me in my xbox controller

brazen hill
#

Huh?

#

wait u edited ur message

#

still doesn't works

pliant cedar
#

try pressing 2 times

brazen hill
#

i tried

#

i even spammed

pliant cedar
#

where did you place the script

brazen hill
#

StarterPlayerScripts

pliant cedar
#

is it a local script?

brazen hill
#

Yep

pliant cedar
#

send me your code here

brazen hill
pliant cedar
#

no like the actual code

brazen hill
#
local UserInputService = game:GetService("UserInputService");
local SelectedShiftLock = Enum.KeyCode.ButtonY; -- here
local players = game:GetService("Players");
local player = players.LocalPlayer;

--Local script in StarterPlayerCharacter
--Services:
local RunService = game:GetService("RunService")
--Variables:
local char = player.CharacterAdded:Wait();
local hum = char:WaitForChild("Humanoid")
local root = hum.RootPart -- The HumanoidRootPart


--Toggle Function:
function shiftLock(active) --Toggle shift.lock function
    if active then        
        hum.CameraOffset = Vector3.new(1.75,0,0) -- I assume this is about the right camera offset.
        hum.AutoRotate = false --Disable the automatic rotation since we are the ones setting it.

        RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
            UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter --Set the mouse to center every frame.

            local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
            root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0,y,0) --Set the root part to the camera's rotation
        end) 
    else
        hum.AutoRotate = true --Let the humanoid handle the camera rotations again.
        hum.CameraOffset = Vector3.new(0,0,0) --Move the camera back to normal.
        RunService:UnbindFromRenderStep("ShiftLock") -- Allow mouse to move freely.
        UserInputService.MouseBehavior = Enum.MouseBehavior.Default -- Let the mouse move freely
    end
end

local enabled = false;
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
    local code = input.KeyCode;
    if(code == SelectedShiftLock)then
        if(enabled)then
            shiftLock(true)
        else
            shiftLock(false)
        end
        enabled = not enabled;
    end
end)```
brazen hill
pliant cedar
#

im trying that exact same code and it is working for me

brazen hill
#

strange duh

pliant cedar
#

mmmh

brazen hill
#

I'm searching for everything

#

let me try on xbox controller (if i find it)

pliant cedar
#

you were using ps controller?

brazen hill
#

ye

pliant cedar
#

that shouldnt be the reason but maybe

brazen hill
#

we'll see, xbox one controller time

#

nope, doesnt works too

pliant cedar
#
local UserInputService = game:GetService("UserInputService");
local SelectedShiftLock = Enum.KeyCode.ButtonY; -- here
local players = game:GetService("Players");
local player = players.LocalPlayer;

--Local script in StarterPlayerCharacter
--Services:
local RunService = game:GetService("RunService")
--Variables:
local char = player.CharacterAdded:Wait();
local hum = char:WaitForChild("Humanoid")
local root = hum.RootPart -- The HumanoidRootPart


--Toggle Function:
function shiftLock(active) --Toggle shift.lock function
    if active then        
        hum.CameraOffset = Vector3.new(1.75,0,0) -- I assume this is about the right camera offset.
        hum.AutoRotate = false --Disable the automatic rotation since we are the ones setting it.

        RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
            UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter --Set the mouse to center every frame.

            local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
            root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0,y,0) --Set the root part to the camera's rotation
        end) 
    else
        hum.AutoRotate = true --Let the humanoid handle the camera rotations again.
        hum.CameraOffset = Vector3.new(0,0,0) --Move the camera back to normal.
        RunService:UnbindFromRenderStep("ShiftLock") -- Allow mouse to move freely.
        UserInputService.MouseBehavior = Enum.MouseBehavior.Default -- Let the mouse move freely
    end
end

local enabled = false;
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
    local code = input.KeyCode;
    if(code == SelectedShiftLock)then
                print(code)
        if(enabled)then
            shiftLock(false)
        else
            shiftLock(true)
        end
        enabled = not enabled;
    end
end)
#

try this code and tell me what you get from the output

brazen hill
#

maybe what i should do is make some print

pliant cedar
#

yeah i made a print

brazen hill
pliant cedar
#

its getting detected

#

still no shiftlock?

brazen hill
#

no shiftlock on the controller

#

but on pc, yes

pliant cedar
#

place a print inside here

RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
            UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter --Set the mouse to center every frame.

            local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
            root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0,y,0) --Set the root part to the camera's rotation
        end) ```
(i know, not beautiful)
brazen hill
#

what line is it?

pliant cedar
#

25

brazen hill
#

and where do i put the print?

pliant cedar
#

under line 25

brazen hill
pliant cedar
#

this is so weird, its getting there, but doesnt work

brazen hill
#

yea

#

Wait

#

don't you have any other script that makes it work?

pliant cedar
#

I only have 1 script and its the same you have it seems

brazen hill
#

Do you want me to add you to team create so you figure out?

pliant cedar
#

ok

brazen hill
#

just you need to join my group

#

cuz its a group game

pliant cedar
#

send it

rose grotto
#

Cause you need to disable normal shitflock

#

Custom shitflock x normal shitflock = 🙅‍♂️

limpid meteor
#

83 msgs is crazy

brazen hill
#

I need to disable the shift lock, like players cant enable them in the settings tab?

rose grotto
#

Yep

limpid meteor
#

Balls

harsh lynxBOT
#

studio** You are now Level 15! **studio

rose grotto
#

I'm not fully sure tho but I think it can solve most of your problem