Player Target Lock System

This post was flagged by the community and is temporarily hidden.

Assuming you used Aim Assist by Aphrim then it appears to work by just adding it to the hierarchy. Note, it only aim assists to hostile, live players, so you will need to add a Team Settings object to your hierarchy and set the Team Mode to Free For All to test.

If you want it to aim assist to something else, it should not be hard to figure out where to change the script (remove the checks for players and give it a list of objects instead of players).

You can't just cut and paste out of context - you will see the whole thing is set up in the client context, which is required. Best to build your list of objects within the script. If you want to pass it objects as properties, make sure they exist in the client context.

@RedQuad Okay... I figured out the problem with the attach script. I was trying to attach the object's parent to the player and not the script.parent which is the Core Object I wanted to attach.

I followed all the same steps I did yesterday but this time it worked.

  1. Created a client context.
  2. Created a Core Object in the Client Context
  3. Drag and dropped my script onto the Core Object.

It attached fine this time.. Now to try with the other script.

This script:

local localPlayer = Game.GetLocalPlayer()
local symbiote = script.parent
local target = symbiote:GetCustomProperty("Target"):WaitForObject()

script.parent:AttachToLocalView()


function Tick()

	symbiote:LookAt(target:GetWorldPosition())
	--local playerLookQ = Quaternion.New(localPlayer:GetLookWorldRotation())
	local pointQ = Quaternion.New(symbiote:GetLookWorldRotation())
	--localPlayer:SetLookWorldRotation(pointQ)
	
end

Is now getting this error: attempt to call a nil value (method 'GetLookWorldRotation')

Which doesn't make sense because the object is in the scene and

If you reference GetLookWorldRotation in API Reference you will see it is a function of a Player object, but you are trying to use it on your symbiote, which is not a Player object, hence the error.

This is really just a cut and paste from Aphrim's code (note all the custom properties are on the symbiote object, strength = 15, speed = 3):

local localPlayer = Game.GetLocalPlayer()
local symbiote = script.parent
local target = symbiote:GetCustomProperty("Target"):WaitForObject()
local strength = symbiote:GetCustomProperty('Strength')
local speed = symbiote:GetCustomProperty('Speed')
symbiote.collision = Collision.FORCE_OFF
symbiote:AttachToPlayer(localPlayer, 'head')


function Tick()
    if localPlayer.isDead == true then return end
    symbiote:LookAt(target:GetWorldPosition())
    local rotDif = localPlayer:GetWorldRotation() - symbiote:GetWorldRotation()
    if math.abs(rotDif.x) < strength and math.abs(rotDif.z) < strength then 
        local playerLookQ = Quaternion.New(localPlayer:GetLookWorldRotation())
        local pointQ = Quaternion.New(symbiote:GetWorldRotation())
        localPlayer:SetLookWorldRotation(Rotation.New(Quaternion.Slerp(playerLookQ, pointQ,speed/10)))
        return
    end
end

I already fixed the problem and I don't use that code anymore. Don't even need a attached game object.

Just use the math.atan function.

local localPlayer = Game.GetLocalPlayer()
local target = script:GetCustomProperty("CoreObject")

function Tick()

localPlayer:SetLookWorldRotation(Rotation.New(0,0,(math.atan((target:GetWorldPosition().y - localPlayer:GetWorldPosition().y), (target:GetWorldPosition().x - localPlayer:GetWorldPosition().x)) * 180)/math.pi))

end

You can do a slerp if you want but it wasn't what i needed for my code.