That is my First skill, have Any think to improve or better on script?

I made a skill called pure blaster (my First skill)

https://gyazo.com/329dcac5c09198b32b93b8f1a263f935

That skill fire a blaster that do:

1. Normal damage;
2. Damage per second If you stay on the area.
3. Create a shield for a moment (the shield Will protect you from the next damage)

A lot of people said have a lot of unnecessary things on script, so i need opinions

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PureBlaster = ReplicatedStorage.Skills.Pure.PureBlaster.Remotes.PureBlaster
local Meshes = script.Meshes
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local trainingm = require(game.ServerStorage.TrainingFiles.TrainingModule)
 
 
 
local function pureBlasterF(player)
   
       
    local MindDamage = player.Stats.Mind.Value.Value
    local MindSecondD = player.Stats.Mind.Value.Value * 0.10
   
    local n = math.floor(100 * 10)
   
    local BlasterP = Meshes:WaitForChild("BlasterP"):Clone()
   
    local usingSkill = Instance.new("BoolValue")
    usingSkill.Name = "usingSkill"
    usingSkill.Value = true
    usingSkill.Parent = player
    print("BLASTER ")
    local Character = player.Character
    local Humanoid = Character:WaitForChild("Humanoid")
    local HumanoidRP = Character:WaitForChild("HumanoidRootPart")
    wait(0.2)
   
   
   
 
    local Track =  Humanoid:LoadAnimation(script.Animation)
    Track:Play()
 
    coroutine.wrap(function()
        wait(2)
        HumanoidRP.Anchored = false
    end)()
 
   
    --Hold
    local Folder = Instance.new("Folder",workspace)
    Folder.Name = player.Name.." Blaster"
    Folder.Parent = workspace
   
    Debris:AddItem(Folder,4.5)
    Debris:AddItem(usingSkill,2)
   
   
    local PureB = Meshes:WaitForChild("PureB"):Clone()
    PureB.CFrame = Character:WaitForChild("LeftHand").CFrame
    PureB.Size = Vector3.new(2,2,2)
    PureB.Parent = Folder
   
    local PureB2 = Meshes:WaitForChild("PureB"):Clone()
    PureB2.CFrame = Character:WaitForChild("RightHand").CFrame
    PureB2.Size = Vector3.new(2,2,2)
    PureB2.Parent = Folder
   
    local weld = Instance.new("WeldConstraint")
    weld.Parent = Folder
    weld.Part0 = PureB
    weld.Part1 = Character:WaitForChild("LeftHand")
   
    local weld2 = Instance.new("WeldConstraint")
    weld2.Parent = Folder
    weld2.Part0 = PureB2
    weld2.Part1 = Character:WaitForChild("RightHand")
   
    Debris:AddItem(PureB,1.25)
    Debris:AddItem(PureB2,1.25)
   
   
    wait(0.75)
   
   
    local goal = {}
    goal.Size = PureB.Size + Vector3.new(9,0,0)
    local info = TweenInfo.new(0.2)
    local tween = TweenService:Create(PureB,info,goal)
    tween:Play()
   
    local goal = {}
    goal.Size = PureB2.Size + Vector3.new(9,0,0)
    local info = TweenInfo.new(0.2)
    local tween = TweenService:Create(PureB2,info,goal)
    tween:Play()
 
    if player:FindFirstChild("shield") then
      if player.shield.Value < 3 then
         player.shield.Value = player.Shield.Value + 1
      end  
    else
       local shield = Instance.new("IntValue")
       shield.Name = "shield"
       shield.Value = 1
       shield.Parent = player
    end
 
    coroutine.wrap(function()
          print("Entrei no shield")
          while workspace:FindFirstChild(player.Name.." Blaster"):FindFirstChild("PureB") do
            print("Entrei no shield 2")
            wait(0.5)
          end
          print("Entrei no shield 3")
          player.shield.Value = player.shield.Value - 1
          if player:FindFirstChild("shield").Value == 0 then
             player.shield:Destroy()
          end
       end)()
 
   
     
     
      BlasterP.Parent = Folder
      BlasterP.CFrame = Character:WaitForChild("Head").CFrame * CFrame.new(0,3,-2)
      BlasterP.ParticleEmitter.Rate = n
      BlasterP.Orientation = BlasterP.Orientation + Vector3.new(0,-90,0)
      BlasterP.Size = Vector3.new(1,15,15)
      BlasterP.Anchored = true
 
      BlasterP.Touched:Connect(function(hit) end)
 
     
     coroutine.wrap(function()
       
        while BlasterP.Parent do
         
         
          for _, part in ipairs(BlasterP:GetTouchingParts()) do
              local characterP = part.Parent
              local humanoidP = characterP:FindFirstChild("Humanoid")
              if humanoidP ~= Humanoid then
              if humanoidP then
                if not humanoidP:FindFirstChild("pureHit") then
                 local pureHit = Instance.new("BoolValue",humanoidP)
                 pureHit.Name = "pureHit"
                 humanoidP:TakeDamage(MindSecondD)
                 Debris:AddItem(pureHit,0.4)
                end
                if not humanoidP:FindFirstChild("pureHitF")then
                 local pureHitF = Instance.new("BoolValue",humanoidP)
                 pureHitF.Name = "pureHitF"
                 humanoidP:TakeDamage(MindDamage)
                 Debris:AddItem(pureHitF,4.5)
                end
              end  
              end  
          end
          wait(0.5)
        end
     end)()
       
    local goal = {}
    goal.Size = BlasterP.Size + Vector3.new(100,0,0)
    goal.CFrame = BlasterP.CFrame * CFrame.new(-50,0,0)
    local info = TweenInfo.new(0.1)  
    local tween = TweenService:Create(BlasterP,info,goal)
    tween:Play()
   
   
   
   
   
    tween.Completed:Wait()
    print("TIME TO TRANSPARENCU")
       
   
    local transp = 0.1
         BlasterP.ParticleEmitter.EmissionDirection = Enum.NormalId.Front
         BlasterP.ParticleEmitter.Speed = NumberRange.new(3, 3)
      for count = 1,20,1 do
         BlasterP.ParticleEmitter.LightEmission = BlasterP.ParticleEmitter.LightEmission - 0.2
         BlasterP.ParticleEmitter.Transparency = NumberSequence.new(transp,transp)
         wait(0.1)
         transp = transp + 0.05
      end
 
 
   
   
end
 
local function checkEnable(player)
    if trainingm.GetTraining(player)["Endurance"] ~= "No" or trainingm.GetTraining(player)["Mind"] == "Auto" or player:FindFirstChild("usingSkill") or workspace:FindFirstChild(player.Name.." Blaster") then
       
    else
        player.Character:WaitForChild("HumanoidRootPart").Anchored = true
        pureBlasterF(player)
    end
       
end
 
PureBlaster.OnServerEvent:Connect(checkEnable)
1 Like

A quick observation at first glance; you might want to reduce the length of some of the lines in your script by breaking them up into multiple lines. It helps readability!

Here’s an example from the end of the script:

if trainingm.GetTraining(player)["Endurance"] ~= "No" or trainingm.GetTraining(player)["Mind"] == "Auto" or player:FindFirstChild("usingSkill") or workspace:FindFirstChild(player.Name.." Blaster") then
    ...
else
    ...
end

would become something like

if trainingm.GetTraining(player)["Endurance"] ~= "No"
or trainingm.GetTraining(player)["Mind"] == "Auto"
or player:FindFirstChild("usingSkill")
or workspace:FindFirstChild(player.Name.." Blaster")
then
    ...
else
    ...
end

The reason it helps out is because it makes reading the script more natural, like reading a book - you don’t have to scroll horizontally, instead you can just move down to the next line. In this case, it also visually separates the different parts of the if-statement’s condition, which is also pretty useful.

Some people have hard limits on the lengths of their script lines (usually 80 or 120 characters) or other rules they use to determine when to break up a line, but I usually just eyeball it. Hope that helps :slightly_smiling_face:

2 Likes

Thanks, if have more things you can Tell me :slight_smile: