You can increase the BodyGyro’s power. It looks like you moved so fast that it didn’t even manage to fully rotate.
Try to add a few more 0’s to this:
Also, make sure the dampening is 0, if not, set it to 0 via the script.
You can increase the BodyGyro’s power. It looks like you moved so fast that it didn’t even manage to fully rotate.
Try to add a few more 0’s to this:
Also, make sure the dampening is 0, if not, set it to 0 via the script.
So your Using BodyGyro for Rotating the Body?? and also i’ve seen many People including me Back then Grabbing stuff, other People made, for my game including client sided Anti cheats (which u should never use)! And flying was always detected through BodyGyro.
So heres my Question could this be a Fly exploit Detection???
I mean, BodyGyro is a BodyMover that is used for a whole bunch of different purposes, other than flying…
If you completely rely on BodyGyro to detect flying, then I’d advise you not to, it fits perfectly the use of BodyGyro here
All BodyGyro does is to rotate something, not move it, so a BodyGyro in the character does not nessecarily mean flying…
TL;DR, Yes, if you use such detections. I’d highly advise you not to.
An alternative could be to CFrame directly instead.
Thanks! This Was Very Helpful Especially For An FPS Game! Was wondering how to do this and couldn’t really find anything especially not this simple!
Does this work with Xbox or Mobile?
Should work just fine .
However, if the rotation acts a bit strange, change the following line:
To:
rotation.CFrame = workspace.CurrentCamera.CFrame
Let me know what the results are
Edit (April 2022):
This now works on mobile with no need to change anything.
yeah sorry mind helping me? the rotation isn’t smooth at all and kinda like delayed? or simply it takes a bit to rotate, even with alot of 0 in the gyro.p
https://gyazo.com/fc569400810bdfa20576b278dfa7018c
What is the D property of the BodyGyro set to? Is it set to 0?
it was set to 500, idk ill try to mess around with it a bit
I suggest you to set it to 0. But try to mess around with it and see what works.
I presume this is used when making camera over the shoulder gun systems.
how can i disconnect the lock or shiftlock like when the intermission is the the shiftlock is disconnect or disable or i unequipped tool
shiftLock(false)
If you have a script from the server, you can use remote events to toggle off shift lock for everyone.
i changed the script to this and the mouse is broken, when I disable it, it wont release the mouse
local plr = game:GetService("Players").LocalPlayer
local mouse = plr:GetMouse()
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local rotation = Instance.new("BodyGyro")
local Root = plr.Character.HumanoidRootPart
rotation.P = 1000000
rotation.Parent = hum.RootPart
local conn
function shiftLock(value,active)
if active then
hum.CameraOffset = Vector3.new(value,0.5,0)
rotation.MaxTorque = Vector3.new(0, math.huge, 0)
conn = game:GetService("RunService").RenderStepped:Connect(function()
rotation.CFrame = mouse.Origin
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
end)
else
hum.CameraOffset = Vector3.new(0,0,0)
rotation.MaxTorque = Vector3.new(0, 0, 0)
if conn then conn:Disconnect() end
end
end
game.ReplicatedStorage.Shiftlock.OnClientEvent:Connect(shiftLock)
i fixed it myself the script is very helpfull ty
I’ve an odd problem, where I’ve set the character to R6, but after I implemented this script, and tested it, it’s now an R15 character. What’s going on?
This script does not change any character parts.
Did you change the character from the Avatar editor? Or game settings?
If from avatar editor, try from the game settings.
Game Settings → Avatar → Avatar Type → R6
Man, your code format…
But hey, no offense, I can fix that
Nice anyway!
local plr = nil
local mouse = nil
local char = nil
local hum = nil
local rotation = nil
local conn
local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local Tween1
local Tween2
local data = script.Parent:WaitForChild("Configuration")
local autoshooting = false
local cooldown = false
function shiftLock(shifttype)
if conn then conn:Disconnect() end
if shifttype == "Idle" then
Tween2:Cancel()
Tween1:Cancel()
task.wait()
Tween1:Play()
rotation.MaxTorque = Vector3.new(0, 0, 0)
conn = game:GetService("RunService").RenderStepped:Connect(function()
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
end)
elseif shifttype == "Shoot" then
Tween1:Cancel()
Tween2:Cancel()
task.wait()
Tween2:Play()
rotation.MaxTorque = Vector3.new(0, math.huge, 0)
conn = game:GetService("RunService").RenderStepped:Connect(function()
rotation.CFrame = mouse.Origin
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter
end)
else
task.wait()
Tween2:Cancel()
Tween1:Cancel()
task.wait()
Tween1:Play()
rotation.MaxTorque = Vector3.new(0, 0, 0)
game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default
if conn then conn:Disconnect() end
end
end
script.Parent.Equipped:Connect(function()
UIS.MouseIconEnabled = false
char = script.Parent.Parent
plr = game.Players:GetPlayerFromCharacter(char)
hum = char.Humanoid
mouse = plr:GetMouse()
rotation = Instance.new("BodyGyro")
rotation.P = 1000000
rotation.Parent = hum.RootPart
if Tween1 then
Tween1:Cancel()
end
if Tween2 then
Tween2:Cancel()
end
Tween1 = TweenService:Create(hum,TweenInfo.new(0.3),{CameraOffset = Vector3.new(0,0,0)})
Tween2 = TweenService:Create(hum,TweenInfo.new(0.3),{CameraOffset = Vector3.new(5,0.5,0)})
shiftLock("Idle")
end)
script.Parent.Unequipped:Connect(function()
UIS.MouseIconEnabled = true
task.wait()
shiftLock()
plr = nil
mouse = nil
char = nil
hum = nil
rotation:Destroy()
rotation = nil
if conn then conn:Disconnect() end
end)
local status = false
UIS.InputBegan:Connect(function(Input,System)
if System or script.Parent.Parent:IsA("Backpack") then return end
if Input.KeyCode == Enum.KeyCode.Q then
if status then
shiftLock("Idle")
script.Parent.ShootEnable:FireServer(false)
else
shiftLock("Shoot")
script.Parent.ShootEnable:FireServer(true)
end
status = not status
elseif Input.UserInputType == Enum.UserInputType.MouseButton2 then
shiftLock("Shoot")
script.Parent.ShootEnable:FireServer(true)
elseif Input.UserInputType == Enum.UserInputType.MouseButton1 then
if data.Auto.Value and not cooldown then
autoshooting = true
repeat
script.Parent.Shoot:FireServer(plr:GetMouse().Hit.Position)
task.wait(data.Firerate.Value)
until not autoshooting
cooldown = true
task.wait(data.Firerate.Value)
cooldown = false
else
if not cooldown then
script.Parent.Shoot:FireServer(plr:GetMouse().Hit.Position)
cooldown = true
task.wait(data.Firerate.Value)
cooldown = false
end
end
elseif Input.KeyCode == Enum.KeyCode.R then
script.Parent.Reload:FireServer()
end
end)
UIS.InputEnded:Connect(function(Input,System)
if System or script.Parent.Parent:IsA("Backpack") then return end
if Input.UserInputType == Enum.UserInputType.MouseButton2 then
shiftLock("Idle")
status = false
script.Parent.ShootEnable:FireServer(false)
elseif Input.UserInputType == Enum.UserInputType.MouseButton1 then
autoshooting = false
end
end)
My mouse got locked on the center sometimes, any reason?
Yes, but you can disable it
Like the original shiftlock, the mouse is locked in the center. So the mouse locking is on purpose, but you can easily disable it.
If you want your character to face the mouse/camera without the centering, you can just remove all of these MouseBehavior lines.