Animation Issue - need help

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    To fix my animation problem

  2. What is the issue? Include screenshots / videos if possible!
    So when i press F to safety mode for gun animation
    When i press back F to normal It didnt turn out like Idle Position
    It turn out like causing safety mode animation issue

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Changing the mode of animation
    Nothing work
    Making new safety animation
    nothing work

Video:

Script:
functions.SafeMode = {
Identifier = “SafeMode”,
RUN = function (Player, data)
local Gun = data.Gun
local SafeMode = Gun.Values.SafeMode
if not Player.Character:FindFirstChild(data.Gun.Name) then return end

	local Animation = Player.Character.Humanoid:FindFirstChild("Gun_safemodeAnimation")
	local track
	
	if not Animation then
		Animation = makeAnimation(Player, "safemodeAnimation", data.Settings.safemodeAnimation)
	end

	track = Player.Character.Humanoid:LoadAnimation(Animation)

	local trackData = {
		Player = Player.Name,
		track = track,
		Obj = Animation,
		name = "safemode"
	}

	for i,v in pairs(tracks) do
		if v.Player == Player.Name then
			if v.name == trackData.name then
				table.remove(tracks, i)
			end
		end
	end
	table.insert(tracks, trackData)
	
	Gun.Values.SafeMode.Value = not Gun.Values.SafeMode.Value
	
	if Gun.Values.SafeMode.Value == true then
		if Gun.Parent == Player.Character then
			for i,v in pairs(tracks) do
				if v.Player == Player.Name then
					if v.name == "idle" then
						v.track:Stop()
					end
					
					if v.name == "safemode" then
						v.track:Play()
					end
				end
			end
		end
	else
		if Gun.Parent == Player.Character then
			for i,v in pairs(tracks) do
				if v.Player == Player.Name then
					if v.name == "idle" then
						v.track:Play()
					end

					if v.name == "safemode" then
						v.track:Stop()
					end
				end
			end
		end
	end
end,

}

1 Like

What is your script? So I will know what do you write in there

Im sorry but is it script issue or animation?

If you don’t have script, Why did you select Scripting Support category?

I do have an script
but my only issue is about the feature topic i already post

I know it’s glitch, But I’m pretty sure the issue is not Animation, The issue is Scripting
So tell me your script

script2222.lua (14.4 KB)

Right now roblox studio has issue with copy/paste key
so i cant copy or paste any script

Just click “Ctrl + A” in a script, Then click “Ctrl + C” then click “Ctrl + V” to a comment

local guns = require(game:GetService(“ReplicatedStorage”):WaitForChild(“Modules”).Tools).Guns
local LogsRemote = game:GetService(“ReplicatedStorage”):FindFirstChild(“LOGS”)

local functions = {}
local tracks = {}
local cooldowns = {}

function makeAnimation(Player, Name, Id)
local Object = Instance.new(“Animation”, Player.Character.Humanoid)
Object.Name = “Gun_”…Name
Object.AnimationId = Id

return Object

end

function makeSound(Player, Gun, Name, Id)
local Object = Instance.new(“Sound”, Gun.Handle)
Object.Name = “Gun_”…Name
Object.SoundId = Id

if Name == "hit" then
	Object.PlaybackSpeed = 2.5
end

if Name == "reload" then
	Object.PlaybackSpeed = 0.5
end

return Object

end

function addCooldown(Player, Gun, Cooldown)
spawn(function()
for _,v in pairs(cooldowns) do
if v.Player == Player.Name and v.Gun == Gun then
return
end
end

	local data = {
		Player = Player.Name,
		Gun = Gun
	}

	cooldowns[Player.Name] = data
	wait(Cooldown)
	cooldowns[Player.Name] = nil
end)

end

function checkCooldown(Player, Gun)
if cooldowns[Player.Name] then
for _, v in pairs(cooldowns) do
if v.Player == Player.Name and v.Gun == Gun then
return true
end
end
end
return false
end

function checkHit(Player: Player, Gun, Settings, hitData)
local HumanoidRootPart = Player.Character:FindFirstChild(“HumanoidRootPart”)
local Part = hitData.touch
if not Part then return end

if HumanoidRootPart then
	if (HumanoidRootPart.CFrame.p - Part.CFrame.p).Magnitude <= Settings.range then
		local target: Humanoid

		pcall(function()
			if Part.Parent then
				if Part.Parent:FindFirstChild("Humanoid") then
					target = Part.Parent.Humanoid
				end
			end

			if Part.Parent.Parent then
				if Part.Parent.Parent:FindFirstChild("Humanoid") then
					target = Part.Parent.Parent.Humanoid
				end
			end

			if Part.Parent.Parent.Parent then
				if Part.Parent.Parent.Parent:FindFirstChild("Humanoid") then
					target = Part.Parent.Parent.Parent.Humanoid
				end
			end
		end)

		if target and target.Health > 0 then
			local damage = Settings.damage

			if Part.Name == "Head" then
				damage = Settings.headshotDamage
			end

			target:TakeDamage(damage)
			LogsRemote:FireAllClients(Player, target, damage)
			
			if target.Health < 1 then
				local intvalue = Instance.new("StringValue")
				intvalue.Value = Player.Name
				intvalue.Name = "Killer"
				intvalue.Parent = target.Parent
				
			end
		end

		if target then
			game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireClient(Player, "hit")

			if Gun.Handle:FindFirstChild("Gun_hit") then
				Gun.Handle.Gun_hit:Play()
			end
		end
	end
end

end

function heal(Player, Gun, Settings, hitData)
local HumanoidRootPart = Player.Character:FindFirstChild(“Humanoid”)
local Part = hitData.touch
if not Part then return end

if HumanoidRootPart then
	if (HumanoidRootPart.CFrame.p - Part.CFrame.p).Magnitude <= Settings.range then
		local target

		pcall(function()
			if Part.Parent then
				if Part.Parent:FindFirstChild("Humanoid") then
					target = Part.Parent.Humanoid
				end
			end

			if Part.Parent.Parent then
				if Part.Parent.Parent:FindFirstChild("Humanoid") then
					target = Part.Parent.Parent.Humanoid
				end
			end

			if Part.Parent.Parent.Parent then
				if Part.Parent.Parent.Parent:FindFirstChild("Humanoid") then
					target = Part.Parent.Parent.Parent.Humanoid
				end
			end
		end)

		if target and target.Health > 0 then
			target.Health = target.MaxHealth
		end

		if target then
			game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireClient(Player, "hit")

			if Gun.Handle:FindFirstChild("Gun_hit") then
				Gun.Handle.Gun_hit:Play()
			end
		end
	end
end

end

function ice(Player, Gun, Settings, hitData)
local HumanoidRootPart = Player.Character:FindFirstChild(“Humanoid”)
local Part = hitData.touch
if not Part then return end

if HumanoidRootPart then
	if (HumanoidRootPart.CFrame.p - Part.CFrame.p).Magnitude <= Settings.range then
		local target

		pcall(function()
			if Part.Parent then
				if Part.Parent:FindFirstChild("Humanoid") then
					target = Part.Parent.Humanoid
				end
			end

			if Part.Parent.Parent then
				if Part.Parent.Parent:FindFirstChild("Humanoid") then
					target = Part.Parent.Parent.Humanoid
				end
			end

			if Part.Parent.Parent.Parent then
				if Part.Parent.Parent.Parent:FindFirstChild("Humanoid") then
					target = Part.Parent.Parent.Parent.Humanoid
				end
			end
		end)

		if target and target.Health > 0 then
			if target.Parent:FindFirstChild("ICE") then return end
			local Cube = game:GetService("ReplicatedStorage"):WaitForChild("LocalStorage"):FindFirstChild("ICE"):Clone()
			Cube.Parent = target.Parent
			Cube.Position = target.Parent.HumanoidRootPart.Position
			target.Parent.HumanoidRootPart.Anchored = true
			wait(5)
			Cube:Destroy()
			target.Parent.HumanoidRootPart.Anchored = false
		end

		if target then
			game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireClient(Player, "hit")

			if Gun.Handle:FindFirstChild("Gun_hit") then
				Gun.Handle.Gun_hit:Play()
			end
		end
	end
end

end

function effects(Player, Gun)
spawn(function()
local FirePart = Gun.FirePart

	FirePart.Light.Enabled = true
	FirePart.Flash.Enabled = true

	wait()

	FirePart.Light.Enabled = false
	FirePart.Flash.Enabled = false
end)

end

function rpgShoot(Player, data)
if data.Gun.Values.Ammo.Value > 0 and data.Gun.Values.Reloading.Value == false and data.Gun.Values.SafeMode.Value == false then
local Bullet = game:GetService(“ReplicatedStorage”).LocalStorage.Bullets.Rocket:Clone()
local Ammo = data.Gun.Values.Ammo

	data.Gun.RPG.Rocket.Transparency = 1
	Ammo.Value = Ammo.Value - 1
	
	spawn(function()
		for i = 90,0,-1 do
			pcall(function()
				if data.Gun and data.Gun.Values then
					data.Gun.Values.ReloadTime.Value = i

					if i == 0 then
						data.Gun.RPG.Rocket.Transparency = 0
						data.Gun.Values.Ammo.Value = data.Settings.ammo
					end

					wait(1)
				end
			end)
		end
	end)

	local FirePart = data.Gun.FirePart

	local distance = (FirePart.CFrame.p - data.hitData.pos).magnitude
	Bullet.CFrame = CFrame.new(FirePart.CFrame.p, data.hitData.pos) * CFrame.new(0, 0, -6)
	Bullet.Parent = game.Workspace.Bullets
	Bullet.BodyVelocity.Velocity = Bullet.CFrame.LookVector * 75
	Bullet.Sound:Play()

	Bullet.Touched:Connect(function(Touch)
		Bullet.Explosion:Play()
		local Explosion = Instance.new("Explosion", Bullet)
		Explosion.BlastPressure = 100
		Explosion.BlastRadius = 10
		Explosion.DestroyJointRadiusPercent = 20
		Explosion.ExplosionType = Enum.ExplosionType.NoCraters
		Explosion.Position = Bullet.Position
		Bullet.Transparency = 1
		
		Explosion.Hit:Connect(function(part)
			if game.Players:GetPlayerFromCharacter(part.Parent) then
				wait(0.2)
				if part.Parent:FindFirstChildOfClass("Humanoid").Health < 1 and not part.Parent:FindFirstChildOfClass("StringValue") then
					local intvalue = Instance.new("StringValue")
					intvalue.Value = Player.Name
					intvalue.Name = "Killer"
					intvalue.Parent = part.Parent

				end
			end
		end)
		
		LogsRemote:FireAllClients(Player, Touch.Parent, 'AT4')
		
		wait(1)
		
		Bullet:Destroy()
	end)
end

end

functions.init = {
Identifier = “Init”,
RUN = function (Player, data)
local Gun = data.Gun
local sounds = {
shoot = data.Settings.shootSound,
hit = data.Settings.hitSound,
reload = data.Settings.reloadSound
}

	Gun.Values.Ammo.Value = data.Settings.ammo

	for i, v in pairs(sounds) do
		if not Gun.Handle:FindFirstChild("Gun_"..i) then
			makeSound(Player, Gun, i, v)
		end
	end
end,

}

functions.Equip = {
Identifier = “Equip”,
RUN = function (Player, data)
local Animation = makeAnimation(Player, “idleAnimation”, data.Settings.idleAnimation)
local track

	track = Player.Character.Humanoid:LoadAnimation(Animation)

	if track then
		track:Play()
	end
	
	local trackData = {
		Player = Player.Name,
		track = track,
		Obj = Animation,
		name = "idle"
	}

	for i,v in pairs(tracks) do
		if v.Player == Player.Name then
			if v.name == trackData.name then
				table.remove(tracks, i)
			end
		end
	end
	table.insert(tracks, trackData)
end,

}

functions.Unequip = {
Identifier = “Unequip”,
RUN = function (Player, data)
local anims = {
[“Gun_idleAnimation”] = true,
[“Gun_shootAnimation”] = true,
[“Gun_reloadAnimation”] = true,
[“Gun_safemodeAnimation”] = true,
}

	for i,v in pairs(tracks) do
		if v.Player == Player.Name then
			v.track:Stop()
			v.Obj:Destroy()
		end
	end
	
	for _,v in pairs(Player.Character.Humanoid:GetChildren()) do
		if v:IsA("Animation") then
			v:Destroy()
		end
	end
	
	if data.Gun:FindFirstChild("Values") then
		data.Gun.Values.SafeMode.Value = false
	end
	for _,anim in pairs(Player.Character.Humanoid.Animator:GetPlayingAnimationTracks()) do
		if anims[anim.Name] then
			anim:Stop()
		end
	end
end,

}

functions.Shoot = {
Identifier = “Shoot”,
RUN = function (Player, data)
local Gun = data.Gun
local Ammo = Gun.Values.Ammo
local hitData = data.hitData

	if Player.Character.Humanoid.Health <= 0 then return end
	if not Player.Character:FindFirstChild(data.Gun.Name) then return end
	
	if checkCooldown(Player, Gun.Name) == false then
		addCooldown(Player, Gun.Name, data.Settings.firerate)
		
		if Gun:FindFirstChild("RPG-7") then
			return rpgShoot(Player, data)
		end
		
		local Animation = Player.Character.Humanoid:FindFirstChild("Gun_shootAnimation")
		local track

		if Ammo.Value > 0 and Gun.Values.Reloading.Value == false and Gun.Values.SafeMode.Value == false then
			if not Animation then
				Animation = makeAnimation(Player, "shootAnimation", data.Settings.shootAnimation)
			end
			
			track = Player.Character.Humanoid:LoadAnimation(Animation)

			local trackData = {
				Player = Player.Name,
				track = track,
				Obj = Animation,
				name = "shoot"
			}
			
			for i,v in pairs(tracks) do
				if v.Player == Player.Name then
					if v.name == trackData.name then
						table.remove(tracks, i)
					end
				end
			end
			table.insert(tracks, trackData)

			if track then
				track:Play()
			end

			if Gun.Handle:FindFirstChild("Gun_shoot") then
				Gun.Handle.Gun_shoot:Play()
			end

			Ammo.Value = Ammo.Value - 1
			
			game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireAllClients("bullet", {FirePart = Gun.FirePart, pos = hitData.pos})
			game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireAllClients("hitEffect", hitData)

			if hitData.touch then if hitData.touch.Size ~= hitData.size then return end end
			
			effects(Player, Gun)
			
			if data.Settings.class == "Heal" then
				return heal(Player, Gun, data.Settings, hitData)
			end
			
			if data.Settings.class == "Ice" then
				return ice(Player, Gun, data.Settings, hitData)
			end
			
			checkHit(Player, Gun, data.Settings, hitData)
		end
	end
end,

}

functions.Reload = {
Identifier = “Reload”,
RUN = function (Player, data)
local Gun = data.Gun
local Ammo = Gun.Values.Ammo

	if Gun:FindFirstChild("RPG-7") then
		return
	end
	if not Player.Character:FindFirstChild(data.Gun.Name) then return end

	local Animation = Player.Character.Humanoid:FindFirstChild("Gun_reloadAnimation")
	local track

	if Gun.Values.Reloading.Value == false then
		Gun.Values.Reloading.Value = true
		
		if not Animation then
			Animation = makeAnimation(Player, "reloadAnimation", data.Settings.reloadAnimation)
		end
		
		track = Player.Character.Humanoid:LoadAnimation(Animation)

		local trackData = {
			Player = Player.Name,
			track = track,
			Obj = Animation,
			name = "reload"
		}

		for i,v in pairs(tracks) do
			if v.Player == Player.Name then
				if v.name == trackData.name then
					table.remove(tracks, i)
				end
			end
		end
		table.insert(tracks, trackData)

		if track then
			track:Play()
		end

		if Gun.Handle:FindFirstChild("Gun_reload") then
			Gun.Handle.Gun_reload:Play()
		end

		wait(data.Settings.reloadTime)

		Ammo.Value = data.Settings.ammo
		Gun.Values.Reloading.Value = false
	end
end,

}

functions.SafeMode = {
Identifier = “SafeMode”,
RUN = function (Player, data)
local Gun = data.Gun
local SafeMode = Gun.Values.SafeMode
if not Player.Character:FindFirstChild(data.Gun.Name) then return end

	local Animation = Player.Character.Humanoid:FindFirstChild("Gun_safemodeAnimation")
	local track
	
	if not Animation then
		Animation = makeAnimation(Player, "safemodeAnimation", data.Settings.safemodeAnimation)
	end

	track = Player.Character.Humanoid:LoadAnimation(Animation)

	local trackData = {
		Player = Player.Name,
		track = track,
		Obj = Animation,
		name = "safemode"
	}

	for i,v in pairs(tracks) do
		if v.Player == Player.Name then
			if v.name == trackData.name then
				table.remove(tracks, i)
			end
		end
	end
	table.insert(tracks, trackData)
	
	Gun.Values.SafeMode.Value = not Gun.Values.SafeMode.Value
	
	if Gun.Values.SafeMode.Value == true then
		if Gun.Parent == Player.Character then
			for i,v in pairs(tracks) do
				if v.Player == Player.Name then
					if v.name == "idle" then
						v.track:Stop()
					end
					
					if v.name == "safemode" then
						v.track:Play()
					end
				end
			end
		end
	else
		if Gun.Parent == Player.Character then
			for i,v in pairs(tracks) do
				if v.Player == Player.Name then
					if v.name == "idle" then
						v.track:Play()
					end

					if v.name == "safemode" then
						v.track:Stop()
					end
				end
			end
		end
	end
end,

}

return function (Player, status, data)
local sendData = data

if data.Settings then
	if data.Gun then
		if guns[data.Gun.Name] then
			sendData.Settings = guns[data.Gun.Name]
		else
			return false
		end
	end
end

for _, v in pairs(functions) do
	if v.Identifier == status then
		v.RUN(Player, sendData)
	end
end

end

It’s looks confused, Can you do this?

--Put script in here

local guns = require(game:GetService(“ReplicatedStorage”):WaitForChild(“Modules”).Tools).Guns
local LogsRemote = game:GetService(“ReplicatedStorage”):FindFirstChild(“LOGS”)

local functions = {}
local tracks = {}
local cooldowns = {}

function makeAnimation(Player, Name, Id)
local Object = Instance.new(“Animation”, Player.Character.Humanoid)
Object.Name = “Gun_”…Name
Object.AnimationId = Id

return Object
end

function makeSound(Player, Gun, Name, Id)
local Object = Instance.new(“Sound”, Gun.Handle)
Object.Name = “Gun_”…Name
Object.SoundId = Id

if Name == “hit” then

  • Object.PlaybackSpeed = 2.5*
    end

if Name == “reload” then

  • Object.PlaybackSpeed = 0.5*
    end

return Object
end

function addCooldown(Player, Gun, Cooldown)
spawn(function()
for _,v in pairs(cooldowns) do
if v.Player == Player.Name and v.Gun == Gun then
return
end
end

  • local data = {*

  •   Player = Player.Name,*
    
  •   Gun = Gun*
    
  • }*

  • cooldowns[Player.Name] = data*

  • wait(Cooldown)*

  • cooldowns[Player.Name] = nil*
    end)
    end

function checkCooldown(Player, Gun)
if cooldowns[Player.Name] then
for _, v in pairs(cooldowns) do
if v.Player == Player.Name and v.Gun == Gun then
return true
end
end
end
return false
end

function checkHit(Player: Player, Gun, Settings, hitData)
local HumanoidRootPart = Player.Character:FindFirstChild(“HumanoidRootPart”)
local Part = hitData.touch
if not Part then return end

if HumanoidRootPart then

  • if (HumanoidRootPart.CFrame.p - Part.CFrame.p).Magnitude <= Settings.range then*

  •   local target: Humanoid*
    
  •   pcall(function()*
    
  •   	if Part.Parent then*
    
  •   		if Part.Parent:FindFirstChild("Humanoid") then*
    
  •   			target = Part.Parent.Humanoid*
    
  •   		end*
    
  •   	end*
    
  •   	if Part.Parent.Parent then*
    
  •   		if Part.Parent.Parent:FindFirstChild("Humanoid") then*
    
  •   			target = Part.Parent.Parent.Humanoid*
    
  •   		end*
    
  •   	end*
    
  •   	if Part.Parent.Parent.Parent then*
    
  •   		if Part.Parent.Parent.Parent:FindFirstChild("Humanoid") then*
    
  •   			target = Part.Parent.Parent.Parent.Humanoid*
    
  •   		end*
    
  •   	end*
    
  •   end)*
    
  •   if target and target.Health > 0 then*
    
  •   	local damage = Settings.damage*
    
  •   	if Part.Name == "Head" then*
    
  •   		damage = Settings.headshotDamage*
    
  •   	end*
    
  •   	target:TakeDamage(damage)*
    
  •   	LogsRemote:FireAllClients(Player, target, damage)*
    
  •   	*
    
  •   	if target.Health < 1 then*
    
  •   		local intvalue = Instance.new("StringValue")*
    
  •   		intvalue.Value = Player.Name*
    
  •   		intvalue.Name = "Killer"*
    
  •   		intvalue.Parent = target.Parent*
    
  •   		*
    
  •   	end*
    
  •   end*
    
  •   if target then*
    
  •   	game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireClient(Player, "hit")*
    
  •   	if Gun.Handle:FindFirstChild("Gun_hit") then*
    
  •   		Gun.Handle.Gun_hit:Play()*
    
  •   	end*
    
  •   end*
    
  • end*
    end
    end

function heal(Player, Gun, Settings, hitData)
local HumanoidRootPart = Player.Character:FindFirstChild(“Humanoid”)
local Part = hitData.touch
if not Part then return end

if HumanoidRootPart then

  • if (HumanoidRootPart.CFrame.p - Part.CFrame.p).Magnitude <= Settings.range then*

  •   local target*
    
  •   pcall(function()*
    
  •   	if Part.Parent then*
    
  •   		if Part.Parent:FindFirstChild("Humanoid") then*
    
  •   			target = Part.Parent.Humanoid*
    
  •   		end*
    
  •   	end*
    
  •   	if Part.Parent.Parent then*
    
  •   		if Part.Parent.Parent:FindFirstChild("Humanoid") then*
    
  •   			target = Part.Parent.Parent.Humanoid*
    
  •   		end*
    
  •   	end*
    
  •   	if Part.Parent.Parent.Parent then*
    
  •   		if Part.Parent.Parent.Parent:FindFirstChild("Humanoid") then*
    
  •   			target = Part.Parent.Parent.Parent.Humanoid*
    
  •   		end*
    
  •   	end*
    
  •   end)*
    
  •   if target and target.Health > 0 then*
    
  •   	target.Health = target.MaxHealth*
    
  •   end*
    
  •   if target then*
    
  •   	game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireClient(Player, "hit")*
    
  •   	if Gun.Handle:FindFirstChild("Gun_hit") then*
    
  •   		Gun.Handle.Gun_hit:Play()*
    
  •   	end*
    
  •   end*
    
  • end*
    end
    end

function ice(Player, Gun, Settings, hitData)
local HumanoidRootPart = Player.Character:FindFirstChild(“Humanoid”)
local Part = hitData.touch
if not Part then return end

if HumanoidRootPart then

  • if (HumanoidRootPart.CFrame.p - Part.CFrame.p).Magnitude <= Settings.range then*

  •   local target*
    
  •   pcall(function()*
    
  •   	if Part.Parent then*
    
  •   		if Part.Parent:FindFirstChild("Humanoid") then*
    
  •   			target = Part.Parent.Humanoid*
    
  •   		end*
    
  •   	end*
    
  •   	if Part.Parent.Parent then*
    
  •   		if Part.Parent.Parent:FindFirstChild("Humanoid") then*
    
  •   			target = Part.Parent.Parent.Humanoid*
    
  •   		end*
    
  •   	end*
    
  •   	if Part.Parent.Parent.Parent then*
    
  •   		if Part.Parent.Parent.Parent:FindFirstChild("Humanoid") then*
    
  •   			target = Part.Parent.Parent.Parent.Humanoid*
    
  •   		end*
    
  •   	end*
    
  •   end)*
    
  •   if target and target.Health > 0 then*
    
  •   	if target.Parent:FindFirstChild("ICE") then return end*
    
  •   	local Cube = game:GetService("ReplicatedStorage"):WaitForChild("LocalStorage"):FindFirstChild("ICE"):Clone()*
    
  •   	Cube.Parent = target.Parent*
    
  •   	Cube.Position = target.Parent.HumanoidRootPart.Position*
    
  •   	target.Parent.HumanoidRootPart.Anchored = true*
    
  •   	wait(5)*
    
  •   	Cube:Destroy()*
    
  •   	target.Parent.HumanoidRootPart.Anchored = false*
    
  •   end*
    
  •   if target then*
    
  •   	game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireClient(Player, "hit")*
    
  •   	if Gun.Handle:FindFirstChild("Gun_hit") then*
    
  •   		Gun.Handle.Gun_hit:Play()*
    
  •   	end*
    
  •   end*
    
  • end*
    end
    end

function effects(Player, Gun)
spawn(function()
local FirePart = Gun.FirePart

  • FirePart.Light.Enabled = true*

  • FirePart.Flash.Enabled = true*

  • wait()*

  • FirePart.Light.Enabled = false*

  • FirePart.Flash.Enabled = false*
    end)
    end

function rpgShoot(Player, data)
if data.Gun.Values.Ammo.Value > 0 and data.Gun.Values.Reloading.Value == false and data.Gun.Values.SafeMode.Value == false then
local Bullet = game:GetService(“ReplicatedStorage”).LocalStorage.Bullets.Rocket:Clone()
local Ammo = data.Gun.Values.Ammo

  • data.Gun.RPG.Rocket.Transparency = 1*

  • Ammo.Value = Ammo.Value - 1*

  • spawn(function()*

  •   for i = 90,0,-1 do*
    
  •   	pcall(function()*
    
  •   		if data.Gun and data.Gun.Values then*
    
  •   			data.Gun.Values.ReloadTime.Value = i*
    
  •   			if i == 0 then*
    
  •   				data.Gun.RPG.Rocket.Transparency = 0*
    
  •   				data.Gun.Values.Ammo.Value = data.Settings.ammo*
    
  •   			end*
    
  •   			wait(1)*
    
  •   		end*
    
  •   	end)*
    
  •   end*
    
  • end)*

  • local FirePart = data.Gun.FirePart*

  • local distance = (FirePart.CFrame.p - data.hitData.pos).magnitude*

  • Bullet.CFrame = CFrame.new(FirePart.CFrame.p, data.hitData.pos) * CFrame.new(0, 0, -6)*

  • Bullet.Parent = game.Workspace.Bullets*

  • Bullet.BodyVelocity.Velocity = Bullet.CFrame.LookVector * 75*

  • Bullet.Sound:Play()*

  • Bullet.Touched:Connect(function(Touch)*

  •   Bullet.Explosion:Play()*
    
  •   local Explosion = Instance.new("Explosion", Bullet)*
    
  •   Explosion.BlastPressure = 100*
    
  •   Explosion.BlastRadius = 10*
    
  •   Explosion.DestroyJointRadiusPercent = 20*
    
  •   Explosion.ExplosionType = Enum.ExplosionType.NoCraters*
    
  •   Explosion.Position = Bullet.Position*
    
  •   Bullet.Transparency = 1*
    
  •   *
    
  •   Explosion.Hit:Connect(function(part)*
    
  •   	if game.Players:GetPlayerFromCharacter(part.Parent) then*
    
  •   		wait(0.2)*
    
  •   		if part.Parent:FindFirstChildOfClass("Humanoid").Health < 1 and not part.Parent:FindFirstChildOfClass("StringValue") then*
    
  •   			local intvalue = Instance.new("StringValue")*
    
  •   			intvalue.Value = Player.Name*
    
  •   			intvalue.Name = "Killer"*
    
  •   			intvalue.Parent = part.Parent*
    
  •   		end*
    
  •   	end*
    
  •   end)*
    
  •   *
    
  •   LogsRemote:FireAllClients(Player, Touch.Parent, 'AT4')*
    
  •   *
    
  •   wait(1)*
    
  •   *
    
  •   Bullet:Destroy()*
    
  • end)*
    end
    end

functions.init = {
Identifier = “Init”,
RUN = function (Player, data)
local Gun = data.Gun
local sounds = {
shoot = data.Settings.shootSound,
hit = data.Settings.hitSound,
reload = data.Settings.reloadSound
}

  • Gun.Values.Ammo.Value = data.Settings.ammo*

  • for i, v in pairs(sounds) do*

  •   if not Gun.Handle:FindFirstChild("Gun_"..i) then*
    
  •   	makeSound(Player, Gun, i, v)*
    
  •   end*
    
  • end*
    end,
    }

functions.Equip = {
Identifier = “Equip”,
RUN = function (Player, data)
local Animation = makeAnimation(Player, “idleAnimation”, data.Settings.idleAnimation)
local track

  • track = Player.Character.Humanoid:LoadAnimation(Animation)*

  • if track then*

  •   track:Play()*
    
  • end*

  • local trackData = {*

  •   Player = Player.Name,*
    
  •   track = track,*
    
  •   Obj = Animation,*
    
  •   name = "idle"*
    
  • }*

  • for i,v in pairs(tracks) do*

  •   if v.Player == Player.Name then*
    
  •   	if v.name == trackData.name then*
    
  •   		table.remove(tracks, i)*
    
  •   	end*
    
  •   end*
    
  • end*

  • table.insert(tracks, trackData)*
    end,
    }

functions.Unequip = {
Identifier = “Unequip”,
RUN = function (Player, data)
local anims = {
[“Gun_idleAnimation”] = true,
[“Gun_shootAnimation”] = true,
[“Gun_reloadAnimation”] = true,
[“Gun_safemodeAnimation”] = true,
}

  • for i,v in pairs(tracks) do*
  •   if v.Player == Player.Name then*
    
  •   	v.track:Stop()*
    
  •   	v.Obj:Destroy()*
    
  •   end*
    
  • end*
  • for _,v in pairs(Player.Character.Humanoid:GetChildren()) do*
  •   if v:IsA("Animation") then*
    
  •   	v:Destroy()*
    
  •   end*
    
  • end*
  • if data.Gun:FindFirstChild(“Values”) then*
  •   data.Gun.Values.SafeMode.Value = false*
    
  • end*
  • for _,anim in pairs(Player.Character.Humanoid.Animator:GetPlayingAnimationTracks()) do*
  •   if anims[anim.Name] then*
    
  •   	anim:Stop()*
    
  •   end*
    
  • end*
    end,
    }

functions.Shoot = {
Identifier = “Shoot”,
RUN = function (Player, data)
local Gun = data.Gun
local Ammo = Gun.Values.Ammo
local hitData = data.hitData

  • if Player.Character.Humanoid.Health <= 0 then return end*

  • if not Player.Character:FindFirstChild(data.Gun.Name) then return end*

  • if checkCooldown(Player, Gun.Name) == false then*

  •   addCooldown(Player, Gun.Name, data.Settings.firerate)*
    
  •   *
    
  •   if Gun:FindFirstChild("RPG-7") then*
    
  •   	return rpgShoot(Player, data)*
    
  •   end*
    
  •   *
    
  •   local Animation = Player.Character.Humanoid:FindFirstChild("Gun_shootAnimation")*
    
  •   local track*
    
  •   if Ammo.Value > 0 and Gun.Values.Reloading.Value == false and Gun.Values.SafeMode.Value == false then*
    
  •   	if not Animation then*
    
  •   		Animation = makeAnimation(Player, "shootAnimation", data.Settings.shootAnimation)*
    
  •   	end*
    
  •   	*
    
  •   	track = Player.Character.Humanoid:LoadAnimation(Animation)*
    
  •   	local trackData = {*
    
  •   		Player = Player.Name,*
    
  •   		track = track,*
    
  •   		Obj = Animation,*
    
  •   		name = "shoot"*
    
  •   	}*
    
  •   	*
    
  •   	for i,v in pairs(tracks) do*
    
  •   		if v.Player == Player.Name then*
    
  •   			if v.name == trackData.name then*
    
  •   				table.remove(tracks, i)*
    
  •   			end*
    
  •   		end*
    
  •   	end*
    
  •   	table.insert(tracks, trackData)*
    
  •   	if track then*
    
  •   		track:Play()*
    
  •   	end*
    
  •   	if Gun.Handle:FindFirstChild("Gun_shoot") then*
    
  •   		Gun.Handle.Gun_shoot:Play()*
    
  •   	end*
    
  •   	Ammo.Value = Ammo.Value - 1*
    
  •   	*
    
  •   	game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireAllClients("bullet", {FirePart = Gun.FirePart, pos = hitData.pos})*
    
  •   	game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireAllClients("hitEffect", hitData)*
    
  •   	if hitData.touch then if hitData.touch.Size ~= hitData.size then return end end*
    
  •   	*
    
  •   	effects(Player, Gun)*
    
  •   	*
    
  •   	if data.Settings.class == "Heal" then*
    
  •   		return heal(Player, Gun, data.Settings, hitData)*
    
  •   	end*
    
  •   	*
    
  •   	if data.Settings.class == "Ice" then*
    
  •   		return ice(Player, Gun, data.Settings, hitData)*
    
  •   	end*
    
  •   	*
    
  •   	checkHit(Player, Gun, data.Settings, hitData)*
    
  •   end*
    
  • end*
    end,
    }

functions.Reload = {
Identifier = “Reload”,
RUN = function (Player, data)
local Gun = data.Gun
local Ammo = Gun.Values.Ammo

  • if Gun:FindFirstChild(“RPG-7”) then*

  •   return*
    
  • end*

  • if not Player.Character:FindFirstChild(data.Gun.Name) then return end*

  • local Animation = Player.Character.Humanoid:FindFirstChild(“Gun_reloadAnimation”)*

  • local track*

  • if Gun.Values.Reloading.Value == false then*

  •   Gun.Values.Reloading.Value = true*
    
  •   *
    
  •   if not Animation then*
    
  •   	Animation = makeAnimation(Player, "reloadAnimation", data.Settings.reloadAnimation)*
    
  •   end*
    
  •   *
    
  •   track = Player.Character.Humanoid:LoadAnimation(Animation)*
    
  •   local trackData = {*
    
  •   	Player = Player.Name,*
    
  •   	track = track,*
    
  •   	Obj = Animation,*
    
  •   	name = "reload"*
    
  •   }*
    
  •   for i,v in pairs(tracks) do*
    
  •   	if v.Player == Player.Name then*
    
  •   		if v.name == trackData.name then*
    
  •   			table.remove(tracks, i)*
    
  •   		end*
    
  •   	end*
    
  •   end*
    
  •   table.insert(tracks, trackData)*
    
  •   if track then*
    
  •   	track:Play()*
    
  •   end*
    
  •   if Gun.Handle:FindFirstChild("Gun_reload") then*
    
  •   	Gun.Handle.Gun_reload:Play()*
    
  •   end*
    
  •   wait(data.Settings.reloadTime)*
    
  •   Ammo.Value = data.Settings.ammo*
    
  •   Gun.Values.Reloading.Value = false*
    
  • end*
    end,
    }

functions.SafeMode = {
Identifier = “SafeMode”,
RUN = function (Player, data)
local Gun = data.Gun
local SafeMode = Gun.Values.SafeMode
if not Player.Character:FindFirstChild(data.Gun.Name) then return end

  • local Animation = Player.Character.Humanoid:FindFirstChild(“Gun_safemodeAnimation”)*

  • local track*

  • if not Animation then*

  •   Animation = makeAnimation(Player, "safemodeAnimation", data.Settings.safemodeAnimation)*
    
  • end*

  • track = Player.Character.Humanoid:LoadAnimation(Animation)*

  • local trackData = {*

  •   Player = Player.Name,*
    
  •   track = track,*
    
  •   Obj = Animation,*
    
  •   name = "safemode"*
    
  • }*

  • for i,v in pairs(tracks) do*

  •   if v.Player == Player.Name then*
    
  •   	if v.name == trackData.name then*
    
  •   		table.remove(tracks, i)*
    
  •   	end*
    
  •   end*
    
  • end*

  • table.insert(tracks, trackData)*

  • Gun.Values.SafeMode.Value = not Gun.Values.SafeMode.Value*

  • if Gun.Values.SafeMode.Value == true then*

  •   if Gun.Parent == Player.Character then*
    
  •   	for i,v in pairs(tracks) do*
    
  •   		if v.Player == Player.Name then*
    
  •   			if v.name == "idle" then*
    
  •   				v.track:Stop()*
    
  •   			end*
    
  •   			*
    
  •   			if v.name == "safemode" then*
    
  •   				v.track:Play()*
    
  •   			end*
    
  •   		end*
    
  •   	end*
    
  •   end*
    
  • else*

  •   if Gun.Parent == Player.Character then*
    
  •   	for i,v in pairs(tracks) do*
    
  •   		if v.Player == Player.Name then*
    
  •   			if v.name == "idle" then*
    
  •   				v.track:Play()*
    
  •   			end*
    
  •   			if v.name == "safemode" then*
    
  •   				v.track:Stop()*
    
  •   			end*
    
  •   		end*
    
  •   	end*
    
  •   end*
    
  • end*
    end,
    }

return function (Player, status, data)
local sendData = data

if data.Settings then

  • if data.Gun then*
  •   if guns[data.Gun.Name] then*
    
  •   	sendData.Settings = guns[data.Gun.Name]*
    
  •   else*
    
  •   	return false*
    
  •   end*
    
  • end*
    end

for _, v in pairs(functions) do

  • if v.Identifier == status then*
  •   v.RUN(Player, sendData)*
    
  • end*
    end
    end

I will turn these to a better script then

--A better version of script
–local guns = require(game:GetService(“ReplicatedStorage”):WaitForChild(“Modules”).Tools).Guns
local LogsRemote = game:GetService(“ReplicatedStorage”):FindFirstChild(“LOGS”)

local functions = {}
local tracks = {}
local cooldowns = {}

function makeAnimation(Player, Name, Id)
local Object = Instance.new(“Animation”, Player.Character.Humanoid)
Object.Name = “Gun_”…Name
Object.AnimationId = Id

return Object
end

function makeSound(Player, Gun, Name, Id)
local Object = Instance.new(“Sound”, Gun.Handle)
Object.Name = “Gun_”…Name
Object.SoundId = Id

if Name == “hit” then
Object.PlaybackSpeed = 2.5
end

if Name == “reload” then
Object.PlaybackSpeed = 0.5
end

return Object
end

function addCooldown(Player, Gun, Cooldown)
spawn(function()
for _,v in pairs(cooldowns) do
if v.Player == Player.Name and v.Gun == Gun then
return
end
end

local data = {
	Player = Player.Name,
	Gun = Gun
}

cooldowns[Player.Name] = data
wait(Cooldown)
cooldowns[Player.Name] = nil
end)
end

function checkCooldown(Player, Gun)
if cooldowns[Player.Name] then
for _, v in pairs(cooldowns) do
if v.Player == Player.Name and v.Gun == Gun then
return true
end
end
end
return false
end

function checkHit(Player: Player, Gun, Settings, hitData)
local HumanoidRootPart = Player.Character:FindFirstChild(“HumanoidRootPart”)
local Part = hitData.touch
if not Part then return end

if HumanoidRootPart then
if (HumanoidRootPart.CFrame.p - Part.CFrame.p).Magnitude <= Settings.range then
local target: Humanoid

	pcall(function()
		if Part.Parent then
			if Part.Parent:FindFirstChild("Humanoid") then
				target = Part.Parent.Humanoid
			end
		end

		if Part.Parent.Parent then
			if Part.Parent.Parent:FindFirstChild("Humanoid") then
				target = Part.Parent.Parent.Humanoid
			end
		end

		if Part.Parent.Parent.Parent then
			if Part.Parent.Parent.Parent:FindFirstChild("Humanoid") then
				target = Part.Parent.Parent.Parent.Humanoid
			end
		end
	end)

	if target and target.Health > 0 then
		local damage = Settings.damage

		if Part.Name == "Head" then
			damage = Settings.headshotDamage
		end

		target:TakeDamage(damage)
		LogsRemote:FireAllClients(Player, target, damage)
		
		if target.Health < 1 then
			local intvalue = Instance.new("StringValue")
			intvalue.Value = Player.Name
			intvalue.Name = "Killer"
			intvalue.Parent = target.Parent
			
		end
	end

	if target then
		game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireClient(Player, "hit")

		if Gun.Handle:FindFirstChild("Gun_hit") then
			Gun.Handle.Gun_hit:Play()
		end
	end
end
end
end

function heal(Player, Gun, Settings, hitData)
local HumanoidRootPart = Player.Character:FindFirstChild(“Humanoid”)
local Part = hitData.touch
if not Part then return end

if HumanoidRootPart then
if (HumanoidRootPart.CFrame.p - Part.CFrame.p).Magnitude <= Settings.range then
local target

	pcall(function()
		if Part.Parent then
			if Part.Parent:FindFirstChild("Humanoid") then
				target = Part.Parent.Humanoid
			end
		end

		if Part.Parent.Parent then
			if Part.Parent.Parent:FindFirstChild("Humanoid") then
				target = Part.Parent.Parent.Humanoid
			end
		end

		if Part.Parent.Parent.Parent then
			if Part.Parent.Parent.Parent:FindFirstChild("Humanoid") then
				target = Part.Parent.Parent.Parent.Humanoid
			end
		end
	end)

	if target and target.Health > 0 then
		target.Health = target.MaxHealth
	end

	if target then
		game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireClient(Player, "hit")

		if Gun.Handle:FindFirstChild("Gun_hit") then
			Gun.Handle.Gun_hit:Play()
		end
	end
end
end
end

function ice(Player, Gun, Settings, hitData)
local HumanoidRootPart = Player.Character:FindFirstChild(“Humanoid”)
local Part = hitData.touch
if not Part then return end

if HumanoidRootPart then
if (HumanoidRootPart.CFrame.p - Part.CFrame.p).Magnitude <= Settings.range then
local target

	pcall(function()
		if Part.Parent then
			if Part.Parent:FindFirstChild("Humanoid") then
				target = Part.Parent.Humanoid
			end
		end

		if Part.Parent.Parent then
			if Part.Parent.Parent:FindFirstChild("Humanoid") then
				target = Part.Parent.Parent.Humanoid
			end
		end

		if Part.Parent.Parent.Parent then
			if Part.Parent.Parent.Parent:FindFirstChild("Humanoid") then
				target = Part.Parent.Parent.Parent.Humanoid
			end
		end
	end)

	if target and target.Health > 0 then
		if target.Parent:FindFirstChild("ICE") then return end
		local Cube = game:GetService("ReplicatedStorage"):WaitForChild("LocalStorage"):FindFirstChild("ICE"):Clone()
		Cube.Parent = target.Parent
		Cube.Position = target.Parent.HumanoidRootPart.Position
		target.Parent.HumanoidRootPart.Anchored = true
		wait(5)
		Cube:Destroy()
		target.Parent.HumanoidRootPart.Anchored = false
	end

	if target then
		game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireClient(Player, "hit")

		if Gun.Handle:FindFirstChild("Gun_hit") then
			Gun.Handle.Gun_hit:Play()
		end
	end
end
end
end

function effects(Player, Gun)
spawn(function()
local FirePart = Gun.FirePart

FirePart.Light.Enabled = true
FirePart.Flash.Enabled = true

wait()

FirePart.Light.Enabled = false
FirePart.Flash.Enabled = false
end)
end

function rpgShoot(Player, data)
if data.Gun.Values.Ammo.Value > 0 and data.Gun.Values.Reloading.Value == false and data.Gun.Values.SafeMode.Value == false then
local Bullet = game:GetService(“ReplicatedStorage”).LocalStorage.Bullets.Rocket:Clone()
local Ammo = data.Gun.Values.Ammo

data.Gun.RPG.Rocket.Transparency = 1
Ammo.Value = Ammo.Value - 1

spawn(function()
	for i = 90,0,-1 do
		pcall(function()
			if data.Gun and data.Gun.Values then
				data.Gun.Values.ReloadTime.Value = i

				if i == 0 then
					data.Gun.RPG.Rocket.Transparency = 0
					data.Gun.Values.Ammo.Value = data.Settings.ammo
				end

				wait(1)
			end
		end)
	end
end)

local FirePart = data.Gun.FirePart

local distance = (FirePart.CFrame.p - data.hitData.pos).magnitude
Bullet.CFrame = CFrame.new(FirePart.CFrame.p, data.hitData.pos) * CFrame.new(0, 0, -6)
Bullet.Parent = game.Workspace.Bullets
Bullet.BodyVelocity.Velocity = Bullet.CFrame.LookVector * 75
Bullet.Sound:Play()

Bullet.Touched:Connect(function(Touch)
	Bullet.Explosion:Play()
	local Explosion = Instance.new("Explosion", Bullet)
	Explosion.BlastPressure = 100
	Explosion.BlastRadius = 10
	Explosion.DestroyJointRadiusPercent = 20
	Explosion.ExplosionType = Enum.ExplosionType.NoCraters
	Explosion.Position = Bullet.Position
	Bullet.Transparency = 1
	
	Explosion.Hit:Connect(function(part)
		if game.Players:GetPlayerFromCharacter(part.Parent) then
			wait(0.2)
			if part.Parent:FindFirstChildOfClass("Humanoid").Health < 1 and not part.Parent:FindFirstChildOfClass("StringValue") then
				local intvalue = Instance.new("StringValue")
				intvalue.Value = Player.Name
				intvalue.Name = "Killer"
				intvalue.Parent = part.Parent

			end
		end
	end)
	
	LogsRemote:FireAllClients(Player, Touch.Parent, 'AT4')
	
	wait(1)
	
	Bullet:Destroy()
end)
end
end

functions.init = {
Identifier = “Init”,
RUN = function (Player, data)
local Gun = data.Gun
local sounds = {
shoot = data.Settings.shootSound,
hit = data.Settings.hitSound,
reload = data.Settings.reloadSound
}

Gun.Values.Ammo.Value = data.Settings.ammo

for i, v in pairs(sounds) do
	if not Gun.Handle:FindFirstChild("Gun_"..i) then
		makeSound(Player, Gun, i, v)
	end
end
end,
}

functions.Equip = {
Identifier = “Equip”,
RUN = function (Player, data)
local Animation = makeAnimation(Player, “idleAnimation”, data.Settings.idleAnimation)
local track

track = Player.Character.Humanoid:LoadAnimation(Animation)

if track then
	track:Play()
end

local trackData = {
	Player = Player.Name,
	track = track,
	Obj = Animation,
	name = "idle"
}

for i,v in pairs(tracks) do
	if v.Player == Player.Name then
		if v.name == trackData.name then
			table.remove(tracks, i)
		end
	end
end
table.insert(tracks, trackData)
end,
}

functions.Unequip = {
Identifier = “Unequip”,
RUN = function (Player, data)
local anims = {
[“Gun_idleAnimation”] = true,
[“Gun_shootAnimation”] = true,
[“Gun_reloadAnimation”] = true,
[“Gun_safemodeAnimation”] = true,
}

for i,v in pairs(tracks) do
	if v.Player == Player.Name then
		v.track:Stop()
		v.Obj:Destroy()
	end
end

for _,v in pairs(Player.Character.Humanoid:GetChildren()) do
	if v:IsA("Animation") then
		v:Destroy()
	end
end

if data.Gun:FindFirstChild("Values") then
	data.Gun.Values.SafeMode.Value = false
end
for _,anim in pairs(Player.Character.Humanoid.Animator:GetPlayingAnimationTracks()) do
	if anims[anim.Name] then
		anim:Stop()
	end
end
end,
}

functions.Shoot = {
Identifier = “Shoot”,
RUN = function (Player, data)
local Gun = data.Gun
local Ammo = Gun.Values.Ammo
local hitData = data.hitData

if Player.Character.Humanoid.Health <= 0 then return end
if not Player.Character:FindFirstChild(data.Gun.Name) then return end

if checkCooldown(Player, Gun.Name) == false then
	addCooldown(Player, Gun.Name, data.Settings.firerate)
	
	if Gun:FindFirstChild("RPG-7") then
		return rpgShoot(Player, data)
	end
	
	local Animation = Player.Character.Humanoid:FindFirstChild("Gun_shootAnimation")
	local track

	if Ammo.Value > 0 and Gun.Values.Reloading.Value == false and Gun.Values.SafeMode.Value == false then
		if not Animation then
			Animation = makeAnimation(Player, "shootAnimation", data.Settings.shootAnimation)
		end
		
		track = Player.Character.Humanoid:LoadAnimation(Animation)

		local trackData = {
			Player = Player.Name,
			track = track,
			Obj = Animation,
			name = "shoot"
		}
		
		for i,v in pairs(tracks) do
			if v.Player == Player.Name then
				if v.name == trackData.name then
					table.remove(tracks, i)
				end
			end
		end
		table.insert(tracks, trackData)

		if track then
			track:Play()
		end

		if Gun.Handle:FindFirstChild("Gun_shoot") then
			Gun.Handle.Gun_shoot:Play()
		end

		Ammo.Value = Ammo.Value - 1
		
		game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireAllClients("bullet", {FirePart = Gun.FirePart, pos = hitData.pos})
		game:GetService("ReplicatedStorage"):WaitForChild("GUN"):FireAllClients("hitEffect", hitData)

		if hitData.touch then if hitData.touch.Size ~= hitData.size then return end end
		
		effects(Player, Gun)
		
		if data.Settings.class == "Heal" then
			return heal(Player, Gun, data.Settings, hitData)
		end
		
		if data.Settings.class == "Ice" then
			return ice(Player, Gun, data.Settings, hitData)
		end
		
		checkHit(Player, Gun, data.Settings, hitData)
	end
end
end,
}

functions.Reload = {
Identifier = “Reload”,
RUN = function (Player, data)
local Gun = data.Gun
local Ammo = Gun.Values.Ammo

if Gun:FindFirstChild("RPG-7") then
	return
end
if not Player.Character:FindFirstChild(data.Gun.Name) then return end

local Animation = Player.Character.Humanoid:FindFirstChild("Gun_reloadAnimation")
local track

if Gun.Values.Reloading.Value == false then
	Gun.Values.Reloading.Value = true
	
	if not Animation then
		Animation = makeAnimation(Player, "reloadAnimation", data.Settings.reloadAnimation)
	end
	
	track = Player.Character.Humanoid:LoadAnimation(Animation)

	local trackData = {
		Player = Player.Name,
		track = track,
		Obj = Animation,
		name = "reload"
	}

	for i,v in pairs(tracks) do
		if v.Player == Player.Name then
			if v.name == trackData.name then
				table.remove(tracks, i)
			end
		end
	end
	table.insert(tracks, trackData)

	if track then
		track:Play()
	end

	if Gun.Handle:FindFirstChild("Gun_reload") then
		Gun.Handle.Gun_reload:Play()
	end

	wait(data.Settings.reloadTime)

	Ammo.Value = data.Settings.ammo
	Gun.Values.Reloading.Value = false
end
end,
}

functions.SafeMode = {
Identifier = “SafeMode”,
RUN = function (Player, data)
local Gun = data.Gun
local SafeMode = Gun.Values.SafeMode
if not Player.Character:FindFirstChild(data.Gun.Name) then return end

local Animation = Player.Character.Humanoid:FindFirstChild("Gun_safemodeAnimation")
local track

if not Animation then
	Animation = makeAnimation(Player, "safemodeAnimation", data.Settings.safemodeAnimation)
end

track = Player.Character.Humanoid:LoadAnimation(Animation)

local trackData = {
	Player = Player.Name,
	track = track,
	Obj = Animation,
	name = "safemode"
}

for i,v in pairs(tracks) do
	if v.Player == Player.Name then
		if v.name == trackData.name then
			table.remove(tracks, i)
		end
	end
end
table.insert(tracks, trackData)

Gun.Values.SafeMode.Value = not Gun.Values.SafeMode.Value

if Gun.Values.SafeMode.Value == true then
	if Gun.Parent == Player.Character then
		for i,v in pairs(tracks) do
			if v.Player == Player.Name then
				if v.name == "idle" then
					v.track:Stop()
				end
				
				if v.name == "safemode" then
					v.track:Play()
				end
			end
		end
	end
else
	if Gun.Parent == Player.Character then
		for i,v in pairs(tracks) do
			if v.Player == Player.Name then
				if v.name == "idle" then
					v.track:Play()
				end

				if v.name == "safemode" then
					v.track:Stop()
				end
			end
		end
	end
end
end,
}

return function (Player, status, data)
local sendData = data

if data.Settings then
if data.Gun then
if guns[data.Gun.Name] then
sendData.Settings = guns[data.Gun.Name]
else
return false
end
end
end

for _, v in pairs(functions) do
if v.Identifier == status then
v.RUN(Player, sendData)
end
end
end

So i should test?

To confirm i want to make sure the rest script would work with no issue

Yes, Screenshot the output too

its look like it broke my gun system

I cannot shoot
No animations Work
No ammo
Nothing else work

functions.SafeMode = {
Identifier = “SafeMode”,
RUN = function (Player, data)
local Gun = data.Gun
local SafeMode = Gun.Values.SafeMode
if not Player.Character:FindFirstChild(data.Gun.Name) then return end

	local Animation = Player.Character.Humanoid:FindFirstChild("Gun_safemodeAnimation")
	local track
	
	if not Animation then
		Animation = makeAnimation(Player, "safemodeAnimation", data.Settings.safemodeAnimation)
	end

	track = Player.Character.Humanoid:LoadAnimation(Animation)

	local trackData = {
		Player = Player.Name,
		track = track,
		Obj = Animation,
		name = "safemode"
	}

	for i,v in pairs(tracks) do
		if v.Player == Player.Name then
			if v.name == trackData.name then
				table.remove(tracks, i)
			end
		end
	end
	table.insert(tracks, trackData)
	
	Gun.Values.SafeMode.Value = not Gun.Values.SafeMode.Value
	
	if Gun.Values.SafeMode.Value == true then
		if Gun.Parent == Player.Character then
			for i,v in pairs(tracks) do
				if v.Player == Player.Name then
					if v.name == "idle" then
						v.track:Stop()
					end
					
					if v.name == "safemode" then
						v.track:Play()
					end
				end
			end
		end
	else
		if Gun.Parent == Player.Character then
			for i,v in pairs(tracks) do
				if v.Player == Player.Name then
					if v.name == "idle" then
						v.track:Play()
					end

					if v.name == "safemode" then
						v.track:Stop()
					end
				end
			end
		end
	end
end,

}

I recommend to ask the Scripter that advanced more than me, The script is too long so I cannot help you, Lo siento :sob:

Can anyone here please help me

i already fixed do not worry guys

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.