context
i’m trying to create a general visual effects system that relies on parts. i couldn’t find any general guidelines to follow on my own, so i just winged it. however, i’ve only just started and haven’t made the system yet. i did plan out how the system would work, so i’ll go through it so that you know my intentions with it & how it’d be used, hopefully.
i’ve decided on using parts that are Anchored all the time, with CanCollide, CanQuery and CanTouch as false. those parts would have their Color, Shape, Material, Size & CFrame to represent a visual effect. these parts would be in a object pool, where a effect structure would get parts from the pool as it starts, and then returns the parts back to it.
the effect structure would hold a start, runtime & end function, with the parts it’d be using in a table. it’s runtime function would be executed during every frame, which would update variables on the parts on the previously mentioned table. though, i’m not certain if i should use a Heartbeat or a Renderstepped event.
the object pool is mainly for memory consumption concerns, a lot of visual effects can happen at one time & they generally have a short lifespan, so it seemed wise to stick with it instead of instantiating parts and deleting them.
because of the effect structure, i don’t want to unanchor the part and then weld it for it to follow another part when the effect starts & then revert it back to being anchored and removing the weld, if the effect is ment to follow a part’s position & orientation. i see this method as the last resort option.
e: “is there any specific reason why you don’t want to use the weld method?”
some effects that i’m intending to use have can show up for a few RenderStepped/Heartbeat frames that may appear multiple times within a within a second. this could mean multiple welds being applied during those frames & then being detached in the same frame if it has a short lifetime or in the next few frames, so they end up being a concern for optimization’s sake.
setup
before actually building the system, i wanted to try if the plan actually works first. to be more specific, i wanted to see if tying functionality to either Heartbeat or Renderstepped would have a okay-ish result.
i made a tool for a quick test, when activated, would position a glowing white 2x4 part on a r6 character’s right arm via CFrame. i have tried both Heartbeat and Renderstepped. in those tests, i’d manually remove the Animate local script on the player character to be able to tell if the white part’s position or orientation is desynced from the right arm.
-hierarchy-
🔧 Tool
📜 LocalScript
🧱 Visual
-local script-
local Player = game.Players.LocalPlayer
local Character = nil
if Player.Character and Player.Character.Parent then
Character = Player.Character
else
Player.CharacterAdded:Wait()
end
local Tool = script.Parent
local Active = false
local function Start()
Active = true
end
local function Stop()
Active = false
script.Visual.CFrame = CFrame.new(Vector3.new(0, math.huge, 0))
end
Tool.Activated:Connect(Start)
Tool.Deactivated:Connect(Stop)
Tool.Unequipped:Connect(Stop)
game["Run Service"].Heartbeat:Connect(function(DT:number)
if Active then
script.Visual.CFrame = Character["Right Arm"].CFrame
end
end)
issue
procedure:
- delete the “Animate” local script, in the player character to prevent the walking animation from working so that the part position & orientation desyncs are easier to tell
- set the player character’s walkspeed to 10000
- move around with WASD, check if there’s any positional desync with the part to the right arm when moving at high speeds
- use MouseLockShift or 1st person view, rotate the player character quickly to check for any rotational desync
in my tests, only quick rotations causes the part to desync for both, seemingly at a pivot on the humanoid root part, which is what i want to solve. besides that, i can’t really tell much of a difference between the two:
Heartbeat
RenderStepped
please tell me you searched for answers for this problem
yes, i did. a few terms i used on the searchbar are:
attach anchored part to unanchored part #help-and-feedback:scripting-support
(closest thread was about connecting a player (character’s arm) to a anchored part, which is the reverse of my problem)
part camera jitter #help-and-feedback:scripting-support
(this was the closest thing i could think of to having a syncing problem, as camera stuff often uses Renderstepped, but i couldn’t find anything relevant to my problem)
after the 2nd search, i was clueless to what kind of keyword i should use, so i resorted to making a topic.