I have parts that i’m cloning to create a explosion effect (on the client for performance)
the issue is that the children (textures) are not inside the part when its cloned even though the part it was cloned from has textures on the server
explosions module:
local module = {}
local blockservice = require(game.ServerScriptService.BlockService)
local Particles = require(game.ReplicatedStorage.Modules.Particles)
local renderExplosion = game.ReplicatedStorage.Events.RenderExplosion
function module:createExplosion(pos,range,FX)
for i,block in pairs(blockservice:getNearby(pos,range)) do
renderExplosion:FireAllClients(pos, block)
blockservice:destroy(block.Position)
end
if FX then
Particles.create(FX,pos,Vector3.new(.1,.1,.1),.15)
end
end
return module
At any rate no but with windows 10 im not sure. I know :clone has some odd things about it
Other thing remoteevents are held together to prevent lag. this is just an example to show what i mean, lets say you call a remote 5 times in a 10th of a second, they are called all at once later to prevent lag. so the event maybe not be called exactly when you want it to.
So the actual event may be called after you are doing the destroy function. which i would also like to see.
No. When you call destroy on an instance, all of its children will also have destroy called on them. Destroy sets the parent of an instance to nil, meaning that the instance’s (and all of it’s children) parent will be set to nil.
I don’t believe there is a way to do so, as instantaneous server-client communication is impossible and RemoteEvents do not yield. An idea that comes to mind is to also pass the instance’s children as a parameter, iterate through them on the client, and clone and parent them to the part as well:
Explosions Module:
function module:createExplosion(pos,range,FX)
for i,block in pairs(blockservice:getNearby(pos,range)) do
renderExplosion:FireAllClients(pos, block, block:GetChildren())
blockservice:destroy(block.Position)
end
if FX then
Particles.create(FX,pos,Vector3.new(.1,.1,.1),.15)
end
end
Local script:
local renderExplosion = game.ReplicatedStorage.Events.RenderExplosion
renderExplosion.OnClientEvent:Connect(function(pos, block, children)
local block = block:Clone()
for _,v in (children) do
v:Clone().Parent = block
end
-- Rest of code
end)
This approach would probably be the least time consuming but I’m not entirely sure if it’s that optimal either.
Shouldn’t they just store the block on ReplicatedStorage? And just send the name of the block to the client, and the client can just fetch and clone it?
I don’t know OP’s situation but with the code that they provided, I assumed that blockservice:getNearby() returned an array of BaseParts located inside of workspace that are within the specified range relative to the position they pass through it. They would have to insert every different type of part inside of ReplicatedStorage if that was the case — which in the event they have a fully fledged map, would be very time consuming.