I have the local script that connected to heartbeat to manage movement of the player. This script uses raycasting from HumanoidRootPart. And I have ability for the player – sphere, that spawns inside a player and it has a big radius, so it disturbs raycasting and I want to exclude it from it.
But the sphere itself I create on the server and it creates a problem: the sphere is replicated to the client.
I tried to put abilities that server creates to an specific folder in Workspace and make :GetChildren() from the local script.
But it seems like on the couple of first frames :GetChildren() is not in time to see that the object was spawned while raycast finds the object and because of it my script fails.
A little confused with your approach to solving this problem. Is there an issue trying to replicate from client to server by firing remote events, or does the problem have to do with raycasting?
I don’t replicate anything by myself – Roblox does it itself. It replicates my sphere to the client.
Meantime I do raycasting on the client and I need to exclude this object on the client if the server spawned it.
I put objects that server creates to the specific folder to be able to find them from client.
On the local script I use :GetChildren() of this folder while making raycastParams, but it seems like because of some delay due to replication :GetChildren() is not in time to see that server created an object, while the raycast itself finds it. But of course I want object to be detected on the step of :GetChildren()
You can set up the raycastParams for something like this in a seperate function before you do :GetChildren()
--assume that the sphereRadius is a base part
local params = RaycastParams.new()
params.FilterDescendantsInstances = {sphereRadius}
params.FilterType = Enum.RaycastFilterType.Exclude
Not sure if I can understand your issue without a script, but I suggest using task.delay() or some sort of cooldown/wait(), while raycasting to find the object before using :GetChildren().
Does the sphere spawn by using a local script? If you’re running from client to server, try making a folder in the server then connect back to the client and then server again.