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

Cant figure out how to make gun point to mouse fe. Any ideas on how to fix this?

Asked by 6 years ago

This is the Script and a Local Script fires an event for mousehitposition and player in FE it glitches and the player runs in place when the mouse is moved if you move the mouse as you start running.

e = false
script.Parent.Equipped:connect(function()
    e = true
end)
script.Parent.Unequipped:connect(function()
    e = false
    print("unequipped")
end)
script.Parent.MousePosEvent.OnServerEvent:connect(function(player, mpos)

local character = player.Character
if not character or not character.Parent then
    character = player.CharacterAdded:wait()
    tor = character:WaitForChild("HumanoidRootPart")
    hum = character:WaitForChild("Humanoid")
end
local cam = game.Workspace.CurrentCamera
local equipped = false
local tor = character.HumanoidRootPart
local hum = character.Humanoid
--player.CharacterAdded:Connect(function()
--  character = player.Character
    --tor = character:WaitForChild("HumanoidRootPart")
--  hum = character:WaitForChild("Humanoid")
--end)

local prev_mousehit


    if (cam.Focus.p-cam.CoordinateFrame.p).magnitude > 1 then
    --  hum.AutoRotate = false
        if mpos ~= prev_mousehit then
            tor.CFrame = CFrame.new(tor.Position, Vector3.new(mpos.x ,tor.Position.y,mpos.z ))
            prev_mousehit = mpos
        end
    else
        hum.AutoRotate = true
    end

end)

Answer this question