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

I am not used to vectorfoce and used bodyvelocity more can someone help me with this?

Asked by
Cikeruw 14
2 years ago

I am trying to make a lightning bolt go to where the mouse hit. But I am used to using bodyvelocity. How can I make this work?

local Part = game.ReplicatedStorage.Wedge

game.ReplicatedStorage.LightningBolt.OnServerEvent:Connect(function(Player)
    local Mouse = Player:GetMouse()

    local Tool = script.Parent
    if Tool then
        if Tool.Parent.Name == Player.Character.Name then


        local partclone = Part:Clone()
        partclone.CanCollide = false
        partclone.CFrame = Player.Character.HumanoidRootPart.CFrame
            local VectorForce = Instance.new("VectorForce")
            partclone.Parent = game.Workspace
        VectorForce.Force = Mouse.Hit.LookVector * 100

        partclone.Touched:Connect(function(hit)
            if hit.Parent:FindFirstChild("Humanoid")then
                if hit.Parent.Name == Player.Character.Name then
                    wait()


                    hit.Parent:FindFirstChild("Humanoid").Health = hit.Parent:FindFirstChild("Humanoid").Health - 5 * Player.leaderstats.Level.Value
                    wait(5)


                    end
                end
            end)
        end
    end
end)

Answer this question