Ad
Log in to vote
0

How do I change the rotation of my bullet holes?

Asked by
Cikeruw 14
21 days ago

I am having trouble making my bullet holes rotating my bullet holes to make the bullet holes flat on the surface. Any help would be nice here is my script:

local RemoteEvent = game.ReplicatedStorage.RemoteEvent2
local Debounce =  false
RemoteEvent.OnServerEvent:Connect(function(Player,mouseCframe,Position)
--  local ray = Ray.new(script.Parent.Position,(Position - script.Parent.Position).unit)
--  local Part, Position, Normal = game.Workspace:FindPartOnRay(ray,nil,false,true)
    local Part = game.ServerStorage.Bullet:Clone()
    local bodyforce = Instance.new("BodyForce")
    bodyforce.Force = Vector3.new(0,Part:GetMass()*workspace.Gravity,0)
    bodyforce.Parent = Part
    Part.CanCollide = false
    Part.Name = "Bullet"
    Part.Parent = game.Workspace
    Part.Anchored = false
    Part.Position = script.Parent.Position
    Part.AssemblyLinearVelocity = mouseCframe 
    Part.Touched:Connect(function(hit)
        if hit.Parent.Name ~= Player.Name then
        if hit.Parent:FindFirstChild("Humanoid") then
            print('E')

                hit.Parent:FindFirstChild("Humanoid"):TakeDamage(5)
                Part:Destroy()
            elseif hit.Name ~= script.Parent.Name and hit.Name ~= "bullet hole"and hit.Name ~= "Bullet"then

                    print(hit.Name)
                local collision_position = Part.Position
                print(collision_position)
        Part:Destroy()
                local bullethole = game.ServerStorage["bullet hole"]:Clone()
                bullethole.Parent = game.Workspace
                bullethole.Position = Position
                bullethole.CanCollide = false
            end
        end
    end)
end)

1 answer

Log in to vote
0
Answered by 21 days ago
bullethole.CFrame = CFrame.lookAt(raycast.Position, raycast.Position + raycast.Normal)
Ad

Answer this question