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

How'd I fix CFrame.new(Position1, Position2)?

Asked by 9 years ago

I'm kind of practicing my skills on a gun, and I want the gun to point at my mouse. Here's what I got for now:

local user = nil
local player = nil

script.Parent.Equipped:connect(function(mouse)
    user = script.Parent.Parent
    player = game.Players:GetPlayerFromCharacter(user)
    player.CameraMode = "LockFirstPerson"
    while wait() do
        script.Parent.Handle.CFrame = CFrame.new(script.Parent.Handle.Position, user.Humanoid.TargetPoint)
    end
end)

script.Parent.Unequipped:connect(function()
    if player ~= nil then
        player.CameraMode = "Classic"
    end
end)

Clean, no errors. But it follows my mouse, and my character's going forward. It's annoying, and would make me fall down from the BasePlate and die. Changing while wait() do end to something such as script.Parent.Handle.Changed:connect(function() end) or adding gyro, would be nice ideas, but I tried script.Parent.Handle.Changed:connect(function() end) and it didn't work, and adding gyro'd make it unable to jump.

Any ideas?

Thanks,

SwaggyDuckie.

0
This is quite a common question. I have made an answer before hand that should help you accomplish this, which you can find here (Be sure to read the comments I've made as well, you need to store the shoulder Motor6Ds in a variable then set Part1 of each Shoulder to nil for it to work): https://scriptinghelpers.org/questions/17657/make-arms-follow-mouse-like-fps#21126 Spongocardo 1991 — 9y

Answer this question