| Refx 0.3.2 Refx is a simple and lightweight library for Replicating Visual Effects in your roblox games. The core principle of refx is to not instantiate anything on server side.
Library achieves this by providing a proxy table as an interface to work with on server side, that internally sends remote requests to client under the hood. Refx also comes with built-in lifetime checker, that makes sure all effects get destroyed properly and warns you about memory leaks you made.
Been waiting for this, I think it’s awesome that you included custom methods with this one. I also like how well it works together with WCS, amazing work.
-- SERVICES
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- MODULES
local refx = require(ReplicatedStorage.Packages.refx)
local Dantian = refx.CreateEffect("Dantian")
function Dantian:OnConstruct()
self.DestroyOnEnd = false
self.DestroyOnLifecycleEnd = false
self.Dantian = nil
print(self)
end
function Dantian:OnStart(player)
local Character = player.Character
if not Character then return end
local dantian = workspace.Effects:FindFirstChild(player.Name .. "Dantian")
if dantian then
self:Destroy()
else
local clone = ReplicatedStorage.Shared.EffectStorage.DantianCore:Clone()
clone.CFrame = CFrame.new(0,10,0)
clone.Name = player.Name .. "Dantian"
clone.Parent = workspace.Effects
self.Dantian = clone
print(self)
end
end
function Dantian:OnDestroy()
print("Destroyed Effect",self)
-- self.Dantian:Destroy()
print(self)
end
return Dantian
when i try to destroy the part it says index nil with destroy so i printed self when destroy fires and self.Dantian doesn’t exist there but it does in the onstart print(self).
Am i doing this wrong?
you fire self:Destroy() in the first statement which invokes OnDestroy before you assign the class fields, I suggest not calling self:Destroy() manually
if you put it in OnStart() you have to provide them when doing Effect.new(...),
if you want a custom method provide them when you call it: proxt:DoSomething(...)
i want the effect to last indefinitely. I was going for a player is meditating and the effect gets spawned and until they stop meditating the effect stays, how would i achieve that?
-- SERVICES
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- MODULES
local wcs = require(ReplicatedStorage.Packages.wcs)
local Warp = require(ReplicatedStorage.Packages.warp)
local DantianEffect = require(ReplicatedStorage.Shared.Effects.Dantian)
-- REMOTES --
local CULTIVATE = Warp.Signal("Cultivate")
local Cultivate = wcs.RegisterSkill("Cultivate")
function Cultivate:OnStartServer(player,...)
print(player,...)
CULTIVATE:Fire(player)
local effect = DantianEffect.new(player)
if player.IsCultivating.Value == true then
print("Starting")
effect:Start(Players:GetPlayers())
elseif player.IsCultivating.Value == false then
print("Destroying")
effect:Destroy()
end
self:ApplyCooldown(1)
end
return Cultivate
am i doing this wrong? because OnDestroy() doesnt happen i have print to check that effect:Destroy() works but the OnDestroy() function doesnt happen
you’re destroying an effect you just made. what you want to do here is make a class field self.Effect = DantianEffect.new(player) and destroy it inside OnEndServer()