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

My Script is supposed to make the player go to the mouse position, can anyone help?

Asked by 3 years ago

Everything except the bodythrust part works

local db = false
local UIS = game:GetService("UserInputService")
Part = nil
Beam = nil
BT = nil
Releasable = false
script.Parent.Activated:Connect(function()
    if not db then
    local mouse = game.Players.LocalPlayer:GetMouse()
        local newBeam = Instance.new("Beam", script.Parent.Handle)
        Beam = newBeam
    newBeam.Attachment0 = script.Parent.Handle.Attachment
        local newPart = Instance.new("Part", workspace)
        Part = newPart
    newPart.Transparency = 1
    newPart.CanCollide = false
    newPart.Anchored = true
    newPart.Position = mouse.Hit.Position
    local newAttachment = Instance.new("Attachment", newPart)
        newBeam.Attachment1 = newAttachment
        db = true
        wait(.1)
        Releasable = true
        local BodyThrust = Instance.new("BodyThrust")
        BodyThrust.Parent = game.Players.LocalPlayer.Character.HumanoidRootPart
        BodyThrust.Force = game.Players.LocalPlayer.Character.Head.CFrame.lookVector * 2
        BT = BodyThrust
        BodyThrust.Location = mouse.Hit.Position
    end
    end)
UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.E and Releasable then
        Part:Destroy()
        Beam:Destroy()
        BT:Destroy()
        Beam = nil
        Part = nil
        db = false
        BT = nil
        Releasable = false
    end
    end)

Answer this question