Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

cannot find invalid argument #3 (CFrame expected, got function) cframe error, how do i fix?

Asked by
ki4ran 0
2 years ago

i have a problem with my cframe.lookat and it keeps saying 'invalid argument #3 (CFrame expected, got function)' and i cannot see the error anywhere on google and other sites also I'm a bit new to scripting too so I don't really know how to fix this problem and I've tried adding some things to the script but it pops up with different errors and heres the script I'm stuck with

local ball = script.Parent

game.Players.PlayerAdded:Connect(function(Player)


    while wait(0.01) do
            ball.CFrame = CFrame.lookAt Vector3.new(Player.Character.Torso.Position)
    end
end)

also I'm just doing this for testing my scripting but I do need help though

1 answer

Log in to vote
0
Answered by 2 years ago

easy solution, here ya go

local ball = script.Parent

game.Players.PlayerAdded:Connect(function(plr)
    local char = plr.Character or plr.CharacterAdded:wait()

    while true do
        ball.CFrame = CFrame.lookAt(ball.Position, char.Torso.Position)
        wait(0.01)
    end
end)
Ad

Answer this question