How do I make objects fall in the mouse location?

Hi, today I’m trying to make 7 objects fall into the mouse location, I need help and if you can give me a code example and tell me what the code says, thank you!

I want answers related to the subject.
If you have any questions don’t hesitate to tell me!

2 Likes

This category isn’t intended for script requests, however, this is a script I made a while back which is essentially what you described.

It clones parts from ReplicatedStorage and it fires on mouse’s location using :GetMouse()


local CAS = game:GetService("ContextActionService")

local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()

local RadiusX, RadiusZ = 25, 25

local AttackCooldown, LastAttack = 1, os.time()

local AttackAmount = 25

local function Attack(_, State)
    if os.time() - LastAttack >= AttackCooldown then
        local Hit = Mouse.Hit.p
        LastAttack = os.time()
        for i = 1, AttackAmount do
            local NewPosX, NewPosZ = Hit.X + math.random(0, RadiusX), Hit.Z + math.random(0, RadiusZ)
            
            local Part = game:GetService("ReplicatedStorage").Part:Clone()
            Part.Parent = workspace
            Part.Position = Vector3.new(NewPosX, (Hit.y + Part.Size.Y / 2), NewPosZ)
            
            game.Debris:AddItem(Part, 5)
            wait()
        end
    end
end

CAS:BindAction("Attack", Attack, false, Enum.UserInputType.MouseButton1)
1 Like

Thank you! Merry christmas!!!

2 Likes