Hi! I do not know what type of support this should be filed under, but I feel as if there may be a way to do something about this related to scripting so I’m going to ask under scripting support. For my game, I have a VFX handler that sends all the VFX to each persons client for each ability which is great! But with each ability comes new VFX and with new VFX comes a lot of new variables…
--Services
local RS = game:GetService("ReplicatedStorage")
local PLRS = game:GetService("Players")
local TS = game:GetService("TweenService")
--Modules
local hitboxModule = require(RS:WaitForChild("HitboxCreator"))
local cameraModule = require(RS:WaitForChild("ScreenShake"))
--VFX Folders
local animsFolder = RS:WaitForChild("Animations")
local sfxFolder = RS:WaitForChild("Sound Effects")
local vfxFolder = RS:WaitForChild("Effects")
local eventsFolder = RS:WaitForChild("Events")
local abilityRemote = eventsFolder:WaitForChild("AbilityRemote")
--Slam Directory
--Remotes
local slamEvents = eventsFolder:WaitForChild("SlamEvents")
local slamVFX = slamEvents:WaitForChild("SlamVFX")
local slamValidator = slamEvents:WaitForChild("SlamValidator")
local playSlamVFX = slamEvents:WaitForChild("PlaySlamVFX")
--Animations
local slamAnim = animsFolder.SlamAnims:WaitForChild("Slam")
--Effects
local slamRocks = vfxFolder["Slam Effects"]:WaitForChild("SlamRocks")
local slamExplo = vfxFolder["Slam Effects"]:WaitForChild("Explosion")
--Sounds
local whoosh = sfxFolder.SlamSounds:WaitForChild("Whoosh")
local slamImpact = sfxFolder.SlamSounds:WaitForChild("GroundSlam")
--Wow that's quite a few variables!
slamVFX.OnClientEvent:Connect(function(plr)
print("Connected to VFX Handler!")
local pChar = plr.Character
local slam = pChar.Humanoid.Animator:LoadAnimation(slamAnim)
slam:Play()
whoosh:Play()
slam:GetMarkerReachedSignal("Knockback"):Connect(function()
local vTable = hitboxModule.CreateHitbox(pChar, 0, 0, 0, 15, 15 ,15)
slamValidator:FireServer(pChar, vTable)
local pChar = plr.Character
local humanoid = pChar:FindFirstChild("Humanoid")
local hrp = pChar:FindFirstChild("HumanoidRootPart")
local pDirection = hrp.CFrame.LookVector
local victimVFX = playSlamVFX.OnClientEvent:Connect(function(validHit)
cameraModule.smallShake(pChar, 0.5)
slamImpact:Play()
local rocksClone = slamRocks:Clone()
local primaryRock = rocksClone.PrimaryPart
for _, effect in pairs (slamExplo:GetChildren()) do
local effectClone = effect:Clone()
effectClone.Parent = primaryRock
end
local rockTweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local rockTweenProperties = {
["CFrame"] = hrp.CFrame + Vector3.new(0,-3,0)
}
local rockTween = TS:Create(primaryRock, rockTweenInfo, rockTweenProperties)
rocksClone:PivotTo(hrp.CFrame + Vector3.new(0,-5,0))
rocksClone.Parent = workspace
rockTween:Play()
game.Debris:AddItem(rocksClone, 1.2)
if #validHit == 0 then --If nobody was hit this will fire and then stop the script
--print("Nobody was hit!")
return
else
for _, victim in pairs (validHit) do --Any victim related effects go here
end
end
end)
task.delay(3, function()
victimVFX:Disconnect()
end)
end)
end)
Not that I think having a lot of variables is a problem, it’s going to happen if you have a lot of different abilities with different VFX. My question though pertains to asking if there is a way to put all of the variables somewhere else or organize them a bit more? Sort of like a script of a global library with all of my commonly used variables that can be pointed to from anywhere. I just don’t want my VFX Handler to become a jumbled mess of a bunch of variables if I can do something about it.