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

How to make the new instance act like a bullet?

Asked by
pwgth 11
3 years ago

I kinda feel bad for putting whats like my 1000000000000th question here... but either way, do any of you know how to make the new instance in this script move like the bullet of a gun? (turn to the direction of the mouse and move in the mouse's direction) here's the script if needed

local tool = script.Parent
local mouse
local debounce = false 
local dmg = --set damage here

    tool.Equipped:Connect(function(m)
    mouse = m
end)

tool.Activated:Connect(function()
    if mouse then
        local Part = Instance.new("Part",workspace)
        Part.Position = script.parent.muzzle.Position
        Part.Material = Enum.Material.Neon
        Part.Size = Vector3.new(0.5,1,0.5)
        Part.CanCollide = false
        Part.Anchored = true

        Part.Touched:Connect(function(hit)
            local h = hit.Parent:FindFirstChild("Humanoid")
            if h then
                debounce = true
                h:TakeDamage(dmg)
                wait(1)
            end
            debounce = false
        end)
    end
end)

Answer this question