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

I've tried to make the player face towards the mouse it wont work??

Asked by 4 years ago

It's a fly script but it seems to error with CFrame isn't a memeber of playermouse

local uis = game:GetService("UserInputService")
local rs = game:GetService("RunService")
local DigAnimation = Instance.new('Animation')
DigAnimation.AnimationId = "rbxassetid://4332175810"
DAnimation = game.Players.LocalPlayer.Character:WaitForChild("Humanoid", 10):LoadAnimation(DigAnimation)
local button_clicked = false
local myPlayer = game.Players.LocalPlayer
local myChar = myPlayer.Character
local myHRP = myChar:WaitForChild("HumanoidRootPart")
local camera = myPlayer:GetMouse()
local button = script.Parent

local flying = false


local bp = Instance.new("BodyPosition", myHRP)
bp.MaxForce = Vector3.new()
bp.D = 10
bp.P = 10000

local bg = Instance.new("BodyGyro", myHRP)
bg.MaxTorque = Vector3.new()
bg.D = 10
local Forward = Instance.new("BodyGyro",myHRP)

function fly()
     wait()
    myPlayer.CameraMinZoomDistance = (5)
    myPlayer.CameraMaxZoomDistance = (20)
    flying = true
    local button_clicked = false
    DAnimation:Play()
    bp.MaxForce = Vector3.new(10000,10000,10000)
    bg.MaxTorque = Vector3.new(10000,10000,10000)
    while flying do
        wait()
        bp.Position = myHRP.Position +((myHRP.Position - camera.CFrame.p).unit)
        bg.CFrame = CFrame.new(camera.CFrame.p, myHRP.Position)
        Forward.Velocity = camera.Hit.lookVector*150
    end
end

function endFlying()
    wait()
    myPlayer.CameraMinZoomDistance = (0.5)
    myPlayer.CameraMaxZoomDistance = (40)
    local button_clicked = false
    DAnimation:Stop()
    bp.MaxForce = Vector3.new()
    bg.MaxTorque = Vector3.new()
    flying = false
end

button.MouseButton1Down:Connect (function()
    if not flying then
    local button_clicked = false
        fly()
    else
    local button_clicked = false
        endFlying()
    end
end)
0
Mouse.Hit is the CFrame of the mouse in 3D space, it's not a literal CFrame like BasePart.CFrame or Model.CFrame DeceptiveCaster 3761 — 4y
0
what would i say then? Deinonychusaurus 21 — 4y

Answer this question