In this script, I’m trying to add a reload part. I’m trying to make it so when you reload, it takes away the amount of ammo you took from the max ammo. Hard to explain. However, I got an error on the activated part which tells it to shoot.
script.Parent.Activated:Connect(function()
if canshoot and not reloading then
if script.Parent.Ammo <= script.Parent.MaxAmmo and script.Parent.Ammo > 0 then
canshoot = false
Shoot()
for i,v in pairs (shootpart:GetChildren()) do
if v:IsA("SpotLight") or v:IsA("ParticleEmitter") then
v.Enabled = true
print("Shot")
wait(0.05)
v.Enabled = false
end
end
wait(0.3)
canshoot = true
elseif ammo == 0 then
reload()
reloading = true
canshoot = false
wait(reloadTime)
reloading = false
canshoot = true
end
end
end)
script.Parent.Activated:Connect(function()
if canshoot and not reloading then
if script.Parent.Ammo.Value <= script.Parent.MaxAmmo.Value and script.Parent.Ammo.Value > 0 then
canshoot = false
Shoot()
for i,v in pairs (shootpart:GetChildren()) do
if v:IsA("SpotLight") or v:IsA("ParticleEmitter") then
v.Enabled = true
print("Shot")
wait(0.05)
v.Enabled = false
end
end
wait(0.3)
canshoot = true
elseif ammo == 0 then
reload()
reloading = true
canshoot = false
wait(reloadTime)
reloading = false
canshoot = true
end
end
end)