I'm not good at making scripts from scratch, not even a bit when trying to make a gun script or something else, so i take other's people models and heavily modify them to my desire.
If you have ever played in some games like Zombie Tower or Build a hideout and fight, you may know about these guns which used cFrame, welds and transparency animations ( part A set transparency to 1 and part B to make it look like it moved from part A to B ). a user called manofthelol used these features a lot in his weapon creations.
he also probably made a minigun weapon too which used mesh offsets to "rotate" the 6 barrels; i took a modified version of that model which instead of firing parts with BodyForces, it turned into a raycast weapon which when shot, it will make small part fragments which the same color as the target Part shot by it.
the weapon has a main LocalScript called "Shooter"
Tool.Enabled = true
function onActivated()
if not Tool.Enabled then
return
end
Tool.Enabled = false
local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end
local ammo = script.Parent.Ammo
local maxammo = script.Parent.MaxAmmo
firing = true
while firing == true do
wait()
if reloading == false and humanoid.Health >= 1 then
if ammo.Value >= 1 then
ammo.Value = ammo.Value - 1
local targetPos = humanoid.TargetPoint
local lookAt = (targetPos - character.Head.Position).unit
if script.Parent.Recoil.Value < 10 then
script.Parent.Recoil.Value = script.Parent.Recoil.Value + 1
end
if Spin > 50 then
fire(targetPos)
else
wait()
end
end
elseif reloading == false and humanoid.Health < 1 then
Tool:remove()
end
end
Tool.Enabled = true
end
--[[function onActivated2()
if not Tool.Enabled then
return
end
Tool.Enabled = false
local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end
local ammo = script.Parent.Ammo
local maxammo = script.Parent.MaxAmmo
firing = true
while firing == true do
wait()
if reloading == false and humanoid.Health >= 1 then
if ammo.Value >= 1 then
ammo.Value = ammo.Value - 1
local targetPos = humanoid.TargetPoint
local lookAt = (targetPos - character.Head.Position).unit
if script.Parent.Recoil.Value < 10 then
script.Parent.Recoil.Value = script.Parent.Recoil.Value + 1
end
if Spin > 50 then
Spin = 50
else
wait()
end
end
elseif reloading == false and humanoid.Health < 1 then
Tool:remove()
end
end
Tool.Enabled = true
end--]]
the greened out part is supposed to be the mouse2 activation function; you can see the function is identical except it will keep changing the spin value to 50 instead of calling the fire(targetPos) function, because i want the gun to behave like the minigun you see in Valve's Team Fortress 2, if you ever played it.
the minigun's secondary fire will rev up the gun, but will not shoot and when you click Mouse1, it shoots.
https://wiki.teamfortress.com/wiki/Minigun
Players can begin spinning the barrel by holding down secondary fire, which will not fire any ammunition until primary fire is pressed. This can allow the Heavy to quickly respond to enemies when keeping the same position.
but the problem is that if you hold one of the buttons, when clicking the other one, it will stop revving or shooting, forcing the player to manually click the opposite button than you clicked first.
this is the weapon in question https://www.roblox.com/library/943150996/needs-to-be-fixed-minigun
if Spin > 50 then
Spin = 50
else
wait()
end
my idea is to put an and if statement in the current syntax
if Spin > 50 and Button1down == true then
fire(targetPos)
else
??? -- what would i put here if the above syntax worked, though?
end
but how can there be a value to check if button1 or 2 is being pressed or not? exactly, there isn't
then what do i have to do for the gun to not stop revving when holding mouse2 then pressing mouse1 to fire or when firing then pressing mouse2?
(i don't think this is a good topic. i tried to explain as good as i could, though.)

1 comment
here goes my post...