So basically, I made my first fps gun!!! Then, when I tested it, it did no damage to anyone. When I tried fps guns from toolbox, it also did no damage. Games like arsenal have this, but I'm unsure how to make it so you can hit people.
----------------------------------------------------------------------
--------------------[ IGNORE MODEL HANDLING ]-------------------------
----------------------------------------------------------------------
wait(math.random(0, 20) / 40) --This is to prevent more than one ignoreModel from being created
if _G.ignoreCode then --If the ignoreCode already exists, then the script creates the ignoreModel
--[[
The purpose of this is so that every gun in a game that uses this gun kit will share one ignoreModel. That way,
bullet trails, bullet holes, and other fake arms will be ignored by the gun which makes the bullets more likely to
hit a character part
--]]
if (not game.Workspace:FindFirstChild("ignoreModel_".._G.ignoreCode)) then
local ignoreModel = Instance.new("Model")
ignoreModel.Name = "ignoreModel_".._G.ignoreCode
ignoreModel.Parent = game.Workspace
local grenadeFolder = Instance.new("Model")
grenadeFolder.Name = "grenadeFolder"
grenadeFolder.Parent = ignoreModel
spawn(function()
while true do
ignoreModel.Parent = game.Workspace
grenadeFolder.Parent = ignoreModel
wait(1 / 20)
end
end)
end
script.Parent:WaitForChild("clientMain"):WaitForChild("ignoreCode").Value = _G.ignoreCode
else
--[[
If there isn't already an ignoreCode, then this creates one. The purpose of it being random is so that if there is
an ignoreModel for something else in the game, the script won't end up placing the ignored objects in that ignoreModel
--]]
_G.ignoreCode = math.random(1, 1e4)
if (not game.Workspace:FindFirstChild("ignoreModel_".._G.ignoreCode)) then
local ignoreModel = Instance.new("Model")
ignoreModel.Name = "ignoreModel_".._G.ignoreCode
ignoreModel.Parent = game.Workspace
local grenadeFolder = Instance.new("Model")
grenadeFolder.Name = "grenadeFolder"
grenadeFolder.Parent = ignoreModel
spawn(function()
while true do
ignoreModel.Parent = game.Workspace
grenadeFolder.Parent = ignoreModel
wait(1 / 20)
end
end)
end
script.Parent:WaitForChild("clientMain"):WaitForChild("ignoreCode").Value = _G.ignoreCode
end
spawn(function()
--[[
This function deletes any Player Folders that were left in the ignoreModel because the player left the game without
deselecting the Gun first
--]]
repeat wait() until _G.ignoreCode
local ignoreModel = game.Workspace:WaitForChild("ignoreModel_".._G.ignoreCode)
while true do
for _, gunIgnore in pairs(ignoreModel:GetChildren()) do
if gunIgnore.Name ~= "grenadeFolder" then
if (not game.Players:FindFirstChild(gunIgnore.Name:sub(11))) then
gunIgnore:Destroy()
end
end
end
wait(1 / 20)
end
end)
----------------------------------------------------------------------
--------------------[ RESET CAMERA ]----------------------------------
----------------------------------------------------------------------
Gun.ChildRemoved:connect(function(Child)
if Child == Handle and Plyr.Value then
local ignoreCode = Gun:WaitForChild("clientMain"):WaitForChild("ignoreCode").Value
local resetCam = script:WaitForChild("resetCam")
resetCam:WaitForChild("ignoreCode").Value = ignoreCode
resetCam.Parent = Plyr.Value.PlayerGui
end
end)
----------------------------------------------------------------------
--------------------[ GET WELD CFRAMES ]------------------------------
----------------------------------------------------------------------
for _, v in pairs(Gun:GetChildren()) do
if v:IsA("BasePart") and v ~= Handle then
if v:FindFirstChild("mainWeld") then v.mainWeld:Destroy() end
if (not v:FindFirstChild("weldCF")) then
local weldCF = Instance.new("CFrameValue")
weldCF.Name = "weldCF"
weldCF.Value = Handle.CFrame:toObjectSpace(v.CFrame)
weldCF.Parent = v
end
if string.sub(v.Name, 1, 3) == "Mag" then
if (not v:FindFirstChild("magTrans")) then
local magTrans = Instance.new("NumberValue")
magTrans.Name = "magTrans"
magTrans.Value = v.Transparency
magTrans.Parent = v
end
end
v.Anchored = true
v.CanCollide = false
end
end
Handle.Anchored = false
Handle.CanCollide = true
----------------------------------------------------------------------
--------------------[ GUNSETUP HANDLING ]-----------------------------
----------------------------------------------------------------------
---------------------------------------
--Ommited due to lenght----
--------------------------------------
----------------------------------------------------------------------
--------------------[ TWEENJOINT HANDLING ]---------------------------
----------------------------------------------------------------------
local createTweenIndicator = script:WaitForChild("createTweenIndicator")
function createTweenIndicator.OnServerInvoke(_, Joint, newCode)
local tweenIndicator = nil
if (not Joint:findFirstChild("tweenCode")) then --If the joint isn't being tweened, then
tweenIndicator = Instance.new("IntValue")
tweenIndicator.Name = "tweenCode"
tweenIndicator.Value = newCode
tweenIndicator.Parent = Joint
else
tweenIndicator = Joint.tweenCode
tweenIndicator.Value = newCode --If the joint is already being tweened, this will change the code, and the tween loop will stop
end
return tweenIndicator
end
local lerpCF = script:WaitForChild("lerpCF")
function lerpCF.OnServerInvoke(_, Joint, Prop, startCF, endCF, Alpha)
spawn(function()
Joint[Prop] = startCF:lerp(endCF, Alpha)
end)
end
local deleteTweenIndicator = script:WaitForChild("deleteTweenIndicator")
function deleteTweenIndicator.OnServerInvoke(_, tweenIndicator, newCode)
if tweenIndicator.Value == newCode then --If this tween functions was the last one called on a joint then it will remove the code
tweenIndicator:Destroy()
end
end
----------------------------------------------------------------------
--------------------[ BULLET IMPACT HANDLING ]------------------------
----------------------------------------------------------------------
local createBulletImpact = script:WaitForChild("createBulletImpact")
createBulletImpact.OnServerEvent:connect(function(_, H, P, N, D, humanoidFound, gunIgnore, S)
local surfaceCF = CF(P, P + N)
----------------------------------------------------------------------------------
--Creating the bullet hole--------------------------------------------------------
----------------------------------------------------------------------------------
if S.bulletHoles and (not humanoidFound) then
local Hole = Instance.new("Part")
Hole.Transparency = 1
Hole.Anchored = true
Hole.CanCollide = false
Hole.FormFactor = "Custom"
Hole.Size = V3(1, 1, 0.2)
Hole.TopSurface = 0
Hole.BottomSurface = 0
local Mesh = Instance.new("BlockMesh")
Mesh.Offset = V3(0, 0, -0.05)
Mesh.Scale = V3(S.holeSettings.Size, S.holeSettings.Size, 0)
Mesh.Parent = Hole
local Decal = Instance.new("Decal")
Decal.Face = Enum.NormalId.Front
Decal.Texture = S.holeSettings.Texture
Decal.Parent = Hole
Hole.Parent = gunIgnore
Hole.CFrame = surfaceCF
if (not H.Anchored) then
local Weld = Instance.new("Weld", Hole)
Weld.Part0 = H
Weld.Part1 = Hole
Weld.C0 = H.CFrame:toObjectSpace(surfaceCF)
Hole.Anchored = false
end
delay(S.holeSettings.visibleTime, function()
if S.holeSettings.disappearTime > 0 then
local t0 = tick()
while true do
local Alpha = math.min((tick() - t0) / S.holeSettings.disappearTime, 1)
Decal.Transparency = numLerp(0, 1, Alpha)
if Alpha == 1 then break end
wait()
end
Hole:Destroy()
else
Hole:Destroy()
end
end)
end

2 comments
Can you post your script?
sure