So I followed a solution recently and came into a problem(as I usually do)
So basically for some reason concatenation is not working and instead it calls the value “ammo” instead of the full name
Any reason why this is happening?
local damage = {}
local config
function damage.IdentifyGun(gunname, target, muzzleeffect, plr, gunshot, player)
local debounce = false
local character = player.Character or player.CharacterAdded:Wait()
config = script.Configuration
local folder = config:FindFirstChild(gunname)
local damagevar = folder.Damage
local ammovar = folder.Ammo
local clone
local ammovalue = Instance.new("IntValue")
ammovalue.Parent = character
print("fgv")
clone = ammovalue:Clone()
clone.Name = "ammo " .. folder.Name
local counter = 0
for i,v in pairs(character:GetChildren()) do
print("dffg")
if v.Name == clone.Name then
print("gfdgv")
counter +=1
end
if counter >=2 then
print("bruhh")
clone:Destroy()
end
end
local ammo = character:FindFirstChild("ammo " .. gunname)
if ammo == nil then return end
local fireratevar = folder.FireRate
local reloadtimevar = folder.ReloadTime
local maxammovar = folder.MaxAmmo
if target == nil then
return
end
if ammo.Value > 0 and debounce == false then
warn(ammo.Value .. " IS THE AMMO VALUE")
warn(fireratevar.Value .. " IS THE FIRERARE VALUE!")
ammo.Value -=1
muzzleeffect.Enabled = true
gunshot:Play()
debounce = true
if target.Parent:FindFirstChild("Humanoid") then
target.Parent.Humanoid:TakeDamage(damagevar.Value)
end
task.wait(fireratevar.Value)
debounce = false
muzzleeffect.Enabled = false
if ammo.Value == 0 then
debounce = true
task.wait(reloadtimevar.Value)
ammo.Value = maxammovar
debounce = false
return
end
end
end
return damage
local replicatedstorage = game:GetService("ReplicatedStorage")
local rt = replicatedstorage:WaitForChild("Shoot")
local serverscriptserver = game:GetService("ServerScriptService")
local module = require(serverscriptserver.DamageModule)
local soundservice = game:GetService("SoundService")
local sound = soundservice["Gun Shot"]
rt.OnServerEvent:Connect(function(plr, mouse, tool,pos, targetfilter)
local muzzle = tool.Effect.MuzzleEffect
--- print(targetfilter)
targetfilter = tool.Handle
module.IdentifyGun(tool.Name, mouse, muzzle, plr.Name, sound, plr)
end)