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

Why won't my gun script work?

Asked by
iMylo 0
8 years ago

Okay. First off, I have NO experience scripting. Anyways, I was making a gun using TurboFusion's gun kit. I changed some of the settings so that it would fit the description of the gun (the gun is an RPK) However when I tested the gun in game, first it locked my character in place for a few seconds before the gun was "loaded" I guess... and if I held down the mouse to shoot rapidly, the game would freeze and I would have to taskkill roblox. Any help is appreciated. Here is the code:

NOTE: I had to delete some of the comments in the script to shorten it down to less than 10,000 characters.

local Settings = { --These are the settings, change them however you like

GunName = "RPK"; --This is the name that will be displayed on the Tool
Description = ""; --This will be the text that is displayed above the tool when the mouse is hovering over it

GunType = { --[[These are the 5 gun types you can have. Set whichever ones you want to true. (NOTE: Semi and Auto can't both be
    true, and Burst and Auto can't both be true)]]
    Semi = false; --Set this true if you want the gun to be semi-automatic. (Pistols, Snipers, etc)
    Auto = true; --Set this true if you want the gun to be fully automatic. (Assault Rifles, Submachine guns, machine guns, etc)
    Burst = false; --Set this true if you want the gun to be burst fire. (Battle rifles, assault rifles, etc)
    Shot = false; --Set this true if you want the gun to be a shotgun. (NOTE: Shot and auto can both be true)
    Explosive = false; --Set this true if you want the projectiles to be explosive. (Rocket launchers, grenade launchers, etc)
};

BurstAmount = 100; --This is how many bullets will be fired in one burst (if Burst is true)
BurstTime = 0.01; --This is how long it takes for a burst to complete
BurstWait = 0.001; --This is how much time you have to wait before you can fire another burst

ShotAmount = 100; --This is how many bullets will be fired in one shot (if Shot is true)

ExplosionRadius = 10; --This is the radius of the explosion when the bullet hits a target. (If Explosive is true)
ExplosionPressure = 5e5; --This is the pressure of the explosion when the bullet hits the target
ExplosionType = Enum.ExplosionType.NoCraters; --This is the type of explosion
--[[
(0 or "NoCraters" or Enum.ExplosionType.NoCraters) means that the explosion will not damage terrain
(1 or "Craters" or Enum.ExplosionType.Craters) means that the explosion will leave craters in terrain
(2 or "CratersAndDebris" or Enum.ExplosionType.CratersAndDebris) means that the explosion will leave craters and debris in terrain
--]]
ExplosionSound = "rbxassetid://138499093"; --This is what the sound of the explosion will be
ExplosionSoundPitch = 1; --This is what the pitch of the explosion sound will be
ExplosionSoundVolume = 1; --This is what the volume of the explosion sound will be
RayCastExplosions = false; --[[This is whether or not explosions will have raycasting. If this is true, humanoids behind walls
    won't be damaged. If this is false, any humanoid within the radius will be damaged. (NOTE: RangeBasedDamage has to be true in
    order for explosions to have raycasting)]]
RangeBasedDamage = true; --[[This is whether or not will depend on how far the object is from the center of the explosion. If this
    is true, the farther a humanoid is from the blast center, the less damage it'll take. If this is false, any object within
    the explosion's radius will have its joints broken]]

FakeArmTransparency = 0.4; --This is the transparency of the fake arms
FakeArmRealBodyColor = true; --This is whether or not the color of the fake arm will be the color of the player's real arms
FakeArmColor = BrickColor.new("Pastel brown"); --This is what the color of the fake arms will be if FakeArmRealBodyColor is false

ArmC1_UnAimed = { --This table contains the CFrames of the arms when the gun is not aimed
    Left = CFrame.new(0.1, 1.5, -0.3) * CFrame.Angles(0, 0, math.rad(-50)); --This is the cframe of the left arm
    Right = CFrame.new(0.4, 0.25, -0.3) * CFrame.Angles(0, 0, math.rad(25)); --This is the cframe of the right arm
};

ArmC1_Aimed = { --This table contains the CFrames of the arms when the gun is aimed
    Left = CFrame.new(-0.1, 1.2, 0.1) * CFrame.Angles(0, 0, math.rad(-35)); --This is the cframe of the left arm
    Right = CFrame.new(0.3, 0.707, -0.01) * CFrame.Angles(0, 0, math.rad(50)); --This is the cframe of the right arm
};

PlayerAnimations = true; --This is whether or not the player will have custom animations
AimAnimation = true; --This is whether or not there is an animation for aiming down the sights
ReloadAnimation = true; --This is whether or not there is an animation for reloading
StanceAnimation = true; --This is whether or not there is an animation for changing stance

AimSpeed = 0.4; --This is how long the gun will take to fully aim down the sights
MaxZoom = 40; --This is the FOV that the Camera will have when the gun is fully aimed down
HoldMouseOrKeyToADS = true; --This is whether or not you have to hold the right mouse or the ADS key to ADS

FireRate = 600; --This is how many bullets per minute the gun will fire
BulletRange = 1000; --This is how far the bullet will travel before it is no longer effective

InstantHit = false; --[[This is whether or not the bullet will hit a target instantly. If it is false, the bullet will travel at a
    specific speed till it hits a target]]
BulletVelocity = 2400; --This is how fast the bullet will travel in studs per second

Damage = 25; --This is the base damage. That means that this is the least amount of damage that will be inflicted
Multipliers = { --[[These are the damage multipliers. There's a spread of +0.1. That means that if the multiplier is 1, the actual
    multiplier will range from 1 - 1.1]]
    Chest = 1; --This is what the damage will be multiplied by if the bullet hits the chest
    Head = 1.5; --This is what the damage will be multiplied by if the bullet hits the head or a hat
    Limbs = 1; --This is what the damage will be multiplied by if the bullet hits a limb (Arms or legs)
};

AllowFriendlyFire = false; --This is whether or not you can damage teammates
CanDamageNPCs = true; --This is whether or not you can damage NPC's (Zombies, fake players, anything with a humanoid)

RotateWhileSitting = false; --

CanKnife = true;
KnifeMeshId = "http://www.roblox.com/asset/?id=121944778"; 
KnifeTextureId = "http://www.roblox.com/asset/?id=121944805"; 
KnifeCooldown = 0.5; 

BulletColor = BrickColor.new("Bright yellow"); 
BulletTransparency = 0; 
BulletSize = Vector3.new(0.2, 0.2, 4);
BulletMeshSize = Vector3.new(0.5, 0.5, 1); 


BulletTrail = true; 
TrailColor = BrickColor.new("Black"); 
TrailTransparency = 0.6; 
TrailThickness = 0.2; 
TrailVisibleTime = 0.5; 
TrailDisappearTime = 0.5;

BulletHoles = true;
BulletHoleTexture = "http://www.roblox.com/asset/?id=64291961"; 
BulletHoleSize = 0.5; 
BulletHoleVisibleTime = 3; 
BulletHoleDisappearTime = 1; 

Shockwaves = true;
ShockwaveRadius = 0.3; 
ShockwaveColor = BrickColor.new("Light stone grey"); 
ShockwaveDuration = 0.2; 

Penetration = 2; 

BulletDropPerSecond = 0;

Recoil = {
    Aimed = 1;
    Hipfire = 3; 
};
Spread = {
    Hipfire = 20;
    Max = 50; 
    Multiplier = 10;  the Hipfire spread
    Walking = 30;
};

ReloadTime = 1.2; 
AutoReload = true; 

SprintTime = 7; 
StaminaCoolTime = 4; 

DolphinDive = true;
DiveRechargeTime = 1; 

CanChangeStance = true; 
StanceChangeSpeed = 0.25; 
StandOnDeselect = true; 

BaseWalkSpeed = 16; 
SprintSpeed = 25; 
AimedWalkSpeed = 10;
CrouchWalkSpeed = 7;
ProneWalkSpeed = 4; 
LowerStanceKey = "c"; 
RaiseStanceKey = "x";
SprintKey = string.char(48); 
KnifeKey = "f"; 
ADSKey = "q"; make this key ""

}

return Settings

0
This isnt your gun script. Its Turbo fusion. You probably messed with something screwing up the entire code. TrollD3 105 — 8y

Answer this question