So, my brother sent me a gun, with a problem. It causes the player to do weird things when it's equipped. Well, it's not my scripting, so I looked at it, and don't understand what is being done exactly. So, I'm here to ask for help. The various things that happen are: The player is flung, prevented from moving for several seconds, or glitched through the floor.
OnEquipped Function
function OnEquipped(M_Icon)
wait(math.random(10, 40) / 100)
if Humanoid.Health ~= 0 and (not Selected) and Gun.Parent == Character then
Selected = true
BreakReload = false
--------------------[ FAILSAFE RESETING ]-------------------------------------
for _, GM in pairs(Ignore_Model:GetChildren()) do
if GM.Name == "Gun_Ignore_"..Player.Name then
GM:Destroy()
end
end
for _,c in pairs(Connections) do
c:disconnect()
end
Connections = {}
--------------------[ CREATING IGNORE MODELS ]--------------------------------
Gun_Ignore = Instance.new("Model")
Gun_Ignore.Name = "Gun_Ignore_"..Player.Name
Gun_Ignore.Parent = Ignore_Model
--------------------[ MODIFYING THE PLAYER ]----------------------------------
M_Icon.Icon = "rbxasset://textures\\Blank.png"
Gui_Clone = Main_Gui:Clone()
Gui_Clone.Parent = Player.PlayerGui
SetUpGui()
Shoulders.Right.Part1 = nil
Shoulders.Left.Part1 = nil
PrevNeckCF.C0 = Neck.C0
PrevNeckCF.C1 = Neck.C1
BG = Instance.new("BodyGyro", HRP)
BG.maxTorque = VEC3(HUGE, HUGE, HUGE)
BG.Name = "BG"
BG.P = 1e5
BG.cframe = CF(Torso.CFrame.p, Torso.CFrame.p + Torso.CFrame.lookVector)
local PlayerFolder = Instance.new("Model")
PlayerFolder.Name = "PlayerFolder"
PlayerFolder.Parent = Gun_Ignore
local AnimBase = Instance.new("Part")
AnimBase.Transparency = 1
AnimBase.Name = "AnimBase"
AnimBase.CanCollide = false
AnimBase.FormFactor = Enum.FormFactor.Custom
AnimBase.Size = VEC3(0.2, 0.2, 0.2)
AnimBase.BottomSurface = Enum.SurfaceType.Smooth
AnimBase.TopSurface = Enum.SurfaceType.Smooth
AnimBase.Parent = PlayerFolder
AnimWeld = Instance.new("Weld")
AnimWeld.Part0 = AnimBase
AnimWeld.Part1 = Head
AnimWeld.C0 = CF(0, 1, 0)
AnimWeld.Parent = AnimBase
local ArmBase = Instance.new("Part")
ArmBase.Transparency = 1
ArmBase.Name = "ArmBase"
ArmBase.CanCollide = false
ArmBase.FormFactor = Enum.FormFactor.Custom
ArmBase.Size = VEC3(0.2, 0.2, 0.2)
ArmBase.BottomSurface = Enum.SurfaceType.Smooth
ArmBase.TopSurface = Enum.SurfaceType.Smooth
ArmBase.Parent = PlayerFolder
ABWeld = Instance.new("Weld")
ABWeld.Part0 = ArmBase
ABWeld.Part1 = AnimBase
ABWeld.Parent = ArmBase
local LArmBase = Instance.new("Part")
LArmBase.Transparency = 1
LArmBase.Name = "LArmBase"
LArmBase.CanCollide = false
LArmBase.FormFactor = Enum.FormFactor.Custom
LArmBase.Size = VEC3(0.2, 0.2, 0.2)
LArmBase.BottomSurface = Enum.SurfaceType.Smooth
LArmBase.TopSurface = Enum.SurfaceType.Smooth
LArmBase.Parent = PlayerFolder
local RArmBase = Instance.new("Part")
RArmBase.Transparency = 1
RArmBase.Name = "RArmBase"
RArmBase.CanCollide = false
RArmBase.FormFactor = Enum.FormFactor.Custom
RArmBase.Size = VEC3(0.2, 0.2, 0.2)
RArmBase.BottomSurface = Enum.SurfaceType.Smooth
RArmBase.TopSurface = Enum.SurfaceType.Smooth
RArmBase.Parent = PlayerFolder
LWeld = Instance.new("Weld")
LWeld.Name = "LWeld"
LWeld.Part0 = ArmBase
LWeld.Part1 = LArmBase
LWeld.C0 = ArmC0[1]
LWeld.C1 = S.ArmC1_UnAimed.Left
LWeld.Parent = ArmBase
RWeld = Instance.new("Weld")
RWeld.Name = "RWeld"
RWeld.Part0 = ArmBase
RWeld.Part1 = RArmBase
RWeld.C0 = ArmC0[2]
RWeld.C1 = S.ArmC1_UnAimed.Right
RWeld.Parent = ArmBase
LWeld2 = Instance.new("Weld")
LWeld2.Name = "LWeld"
LWeld2.Part0 = LArmBase
LWeld2.Part1 = LArm
LWeld2.Parent = LArmBase
RWeld2 = Instance.new("Weld")
RWeld2.Name = "RWeld"
RWeld2.Part0 = RArmBase
RWeld2.Part1 = RArm
RWeld2.Parent = RArmBase
if S.PlayerArms then
FakeLArm = LArm:Clone()
FakeLArm.Parent = PlayerFolder
FakeLArm.Transparency = S.FakeArmTransparency
FakeLArm:BreakJoints()
LArm.Transparency = 1
local FakeLWeld = Instance.new("Weld")
FakeLWeld.Part0 = FakeLArm
FakeLWeld.Part1 = LArm
FakeLWeld.Parent = FakeLArm
FakeRArm = RArm:Clone()
FakeRArm.Parent = PlayerFolder
FakeRArm.Transparency = S.FakeArmTransparency
FakeRArm:BreakJoints()
RArm.Transparency = 1
local FakeRWeld = Instance.new("Weld")
FakeRWeld.Part0 = FakeRArm
FakeRWeld.Part1 = RArm
FakeRWeld.Parent = FakeRArm
Instance.new("Humanoid", PlayerFolder)
for _,Obj in pairs(Character:GetChildren()) do
if Obj:IsA("CharacterMesh") or Obj:IsA("Shirt") then
Obj:Clone().Parent = PlayerFolder
end
end
else
local ArmTable = CreateArms()
ArmTable[1].Model.Parent = PlayerFolder
ArmTable[2].Model.Parent = PlayerFolder
FakeLArm = ArmTable[1].ArmPart
LArm.Transparency = 1
local FakeLWeld = Instance.new("Weld")
FakeLWeld.Part0 = FakeLArm
FakeLWeld.Part1 = LArm
FakeLWeld.Parent = FakeLArm
FakeRArm = ArmTable[2].ArmPart
RArm.Transparency = 1
local FakeRWeld = Instance.new("Weld")
FakeRWeld.Part0 = FakeRArm
FakeRWeld.Part1 = RArm
FakeRWeld.Parent = FakeRArm
end
--Extra gun effecting code
end
end

3 comments
Is any part in the gun anchored?
Are you sure your brother didn't just copy this from free models?
I'm pretty sure the entire gun is, because he said something about it falling apart otherwise. and He may have. It looks vaguely similar to TurboFusion's gun script.