Hi, I’ve been recently doing a combat system focused punch and kick mixup combos and skills, with a lock on system to make it easier to everyone
the problem is, ive been trying to make a smooth lock on system for a long time now and all my solutions were bad or just didnt work
the one that im currently using and the one i have faith that will work is one that…
- searches for close players on a local script
- if found, sets the closest enemy as a value in a ObjectValue (it does that by sending it to the server, so its set on the server, and not on the client)
- after setting the ObjectValue, a renderstepped loop checks if the value is nil and, updates its cframe to face the enemy thats on the ObjectValue
heres the script
LockOn = RunService.RenderStepped:Connect(function()
for i,player in pairs(Players) do
if player.Character and player.Character.CharacterStats and player.Character.HumanoidRootPart.Anchored == false and player.Character.CharacterStats.Target.Value ~= nil then
local Character = player.Character
if Character.CharacterStats.Target.Value ~= nil then
local EnemyRoot = Character.CharacterStats.Target.Value.HumanoidRootPart
local Root = Character.HumanoidRootPart
local lookAt = Vector3.new(EnemyRoot.Position.X, Root.Position.Y, EnemyRoot.Position.Z)
Root.CFrame = (Root.CFrame:Lerp(CFrame.new(Root.Position, lookAt), 0.6))
end
end
end
end)
this script is located on StarterPlayerScripts, so every player has it and stuff ( its also used for effects replication and sounds)
basically, its still really choppy and i have some clips of players seeing it by other perspectives. On your client, your movements look smooth, but the others are really, REALLY laggy.
i dont know if theres a easy fix for this or not, im thinking about straight up removing lock on because its been giving me so many headaches and i just cant get anything to work
im open to entire new lock on systems as long as it looks good on every client, thanks!