Refx - A library for Replicating Visual Effects in Roblox

:sparkles: | 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.

:books: Documentation

:star2:API

:book: Links:

42 Likes

Amazing work! I was just looking for a tool like this. Thank you very much for your contribution!

4 Likes

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.

1 Like

If effects are started completely on the client, can exploiters fire effects on all players whenever they want?

Sorry if I’m misunderstanding the docs, it’d be helpful (for this and for WCS) to tell us the location of the scripts in the directory.

No. Only server can start the effect for all players.

Can you add a creator marketplace link? Would make it easier to import

where exactly do i get this version?

mb, uploaded the rbxm to release

1 Like
-- 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

hi, i am kinda confused on this part, should i put parameters in :OnStart() like player?

function myEffect:OnStart(player)
    print("myEffect just started! 😅")
end

or in a function?

`function myEffect:DoSomething(player) -- our custom method

end`

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(...)

1 Like

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?

1 Like
function Effect:OnConstruct()
    self.DisableLeakWarning = true
    self.DestroyOnEnd = false
    self.DestroyOnLifecycleEnd = false
end

don’t forget that you’ll make a memory leak if you don’t call :Destroy() manually when they stop meditating, so be careful!!

2 Likes

Do you recommend me making the visuals like projectiles (a sphere/part) on client or server?

Where would I call destroy? Because I want to check if the part exists and if it does then destroy else create it

I mean destroy the effect on server

-- 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()

1 Like