I'm trying to create a third-person-camera lock, and I've never been good at camera manipulation.
I have a decent script so far, however I must use right click to move my character, instead of just being able to move my mouse, and my character moves with it.
Any ideas and/or fixes to this problem?
Script:
local players = game:GetService("Players")
local userInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local userGameSettings = UserSettings().GameSettings
local player = players.LocalPlayer
local enabled = true
runService.RenderStepped:Connect(function()
userGameSettings.RotationType = Enum.RotationType.CameraRelative
if enabled then
userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
end
end)
userInputService.InputBegan:Connect(function(key,gp)
if not gp and key.KeyCode == Enum.KeyCode.LeftAlt then
enabled = not enabled
end
end)
player.CharacterAdded:Connect(function(char)
if char then
local humanoid = char:WaitForChild("Humanoid",60)
if humanoid then
humanoid.CameraOffset = Vector3.new(1,0,0)
end
end
end)
