#center mouse dosnt work

1 messages · Page 1 of 1 (latest)

wind briar
#

Hey I wanted to make it so if you equip a tool you get forced into shiftlock and it doesnt work, the animation dosnt get played, I get no errors and it prints nothing maybe someone can help btw I got the system from a post: https://devforum.roblox.com/t/how-to-force-enable-shift-lock-without-changing-the-playermodule/1072967

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

local tool = script.Parent
local Hanim =  Humanoid.Animator:LoadAnimation(tool.HoldingAnim)


--force shiftlock:
local plr = game:GetService("Players").LocalPlayer
local char = script.Parent
local hum = char:WaitForChild("Humanoid")

local root = hum.RootPart 

--Toggle Function:
function shiftLock(active) 
    if active then

        hum.AutoRotate = false 

        hum.CameraOffset = Vector3.new(1.75,0,0)
        game:GetService("RunService"):BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
            game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter 

            local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() 
            root.CFrame = CFrame.new(root.Position) * CFrame.Angles(0,y,0)

        end) 
    end
end

tool.Equipped:Connect(function()
    Hanim:Play()
    shiftLock(true)
    print("equiped")
end)

tool.Unequipped:Connect(function()
    Hanim:Stop()
    shiftLock(false)
    print("unequiped")
end)
pliant portal
#

-- Inside a LocalScript
I think this is example how to, btw I'm on mobile so I can't test if it's working or not

local UserInputService = game:GetService("UserInputService")


local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()

local humanoid = character:WaitForChild("Humanoid")

UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.MouseIconEnabled = false
UserInputService.MouseBehavior = Enum.MouseBehavior.Default

humanoid.AutoRotate = false
#

@wind briar