To do so, I still need to create something. In this case - ObjectValue. It needs time to replicate too. I can’t pre-create it, because of custom building system. Player can place 1 structure, can place 10 of them. And SINGULAR module script handles all same structures.
Create the part in server and call in client without needing re
What you meant with that? I do 1:1 the same, but with model.
I need to use RE to begin in the case of disco ball animation.
I mean in your shown script, you just used re to get the part which can be automatically be obtained by path. Also try printing the obtained value from re
There are a few things you can do.
As many have said before, you could just add a wait before sending the event, but as you said, that’s not ideal. And I agree with that.
If the parts that are created are organized, then you could sends the client the path to the part instead of the part itself. Then on the client, you would do WaitForChild or such to let the part load into where it is supposed to be.
Well tbh it doesn’t even have to be organized by you. The important thing with this approach would be that every child under a parent (that are related to the parh) would have unique names. You could just have the server generate a random blob of letters for the name of the part and send that along with the path.
Another thing (Though not as good as the last option imo) would be to keep having a forth and back “conversation” with the server.
Every time the server sends the client a part, the client would send an event back (presumably with a little delay) if they received the part as nil, which would tell the server to send that part again. For this to be synchronized correctly, the server should also send like a part index or whatever along with the part, so that if the server receives an event back, it’d know which part was received as nil.
Perhaps you could also try doing what you’re doing a bit backwards. So when the client detects a part being added, it would either ask the server what data should come along with that part, or the required data could be inscribed to the attributes of the part. Tho the second option might become ugly.
Another thing that comes to mind could also work depending on your usecase. The server tells the client how many parts there are supposed to be in total, and once the client detects that the benchmark has been hit, it tells the server to start sending specific data & instructions. I personally like this approach, since it feels like it could be implemented the easiest.
so use task.spawn:
--Server
local Part = Instance.new("Part")
Part.Parent = workspace
local remoteFunction = game:GetService("ReplicatedStorage").Remote
task.spawn(function()
if not remoteFunction:InvokeClient(Player, Part) then
repeat
task.wait(2)
until remoteFunction:InvokeClient(Player, Part)
end
end)
or use remote events:
--Server
local Part = Instance.new("Part")
Part.Parent = workspace
local remoteEvent = game:GetService("ReplicatedStorage").Remote
remoteEvent.OnServerEvent:Connect(function(player)
if player == Player then
task.wait(2)
remoteEvent:FireClient(Player, Part)
end
end)
remoteEvent:FireClient(Player, Part)
--Client
local remote = game:GetService("ReplicatedStorage").Remote
remote.OnClientEvent:Connect(function(Part)
if Part then
Part.Color = Color3.fromRGB(255, 0, 0)
else
remote:FireServer()
end
end)
That ideas are good. Assuming that I have already done alot of custom replications for diffirent stats, I wonder - is there any way to get a signal when instance with specific attribute appears? Because rn, for great 90% of game, stats like “Level”, “Health”, “Owner” and such are done with custom replicator, with DataId
attribute under instances, which is unique (at least until roblox number overflow). So, script can retrieve some values from INSTANCE’s attribute. That system worked well because instances weren’t needed to be replicated at all - just table values.
So, I’ll try to do that as a “path”, thanks.
Never make that again.
If client leaves while function invoked, script will never finish yielding.
why does it matter? it’s in a task.spawn function so the rest of the script will run anyway
It hogs resources, and will be one of memory leaks.
It should be OnServerInvoke or OnServerEvent instead of OnClientEvent I think
Is your plan to make an object on the server and then tell the client to do stuff with it? Or more like just tell the client there is a part?
can you do
workspace.GameObjects.Islands.DescendantAdded:Connect(function(Item : instance)
if item:GetAttribute("DataId") then
-- do stuff
end
end)
if Ping > waitTime and math.random(0, 1) == 0 then error("attempt to index nil with PROPERTY", math.huge) end
what is this?
It means that it won’t work if ping is bigger than wait time.
You can use remote function to get the part as follows:
Server
local PlayerPart = {}
game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(Player)
if not PlayerPart[Player] then
PlayerPart[Player] = Instance.new("Part", workspace)
end
return PlayerPart[Player]
end
Client
local Part
while not Part do
Part = game.ReplicatedStorage.RemoteFunction:InvokeServer()
end
print(Part:GetFullName())
InvokeServer will yield until the function returns a value this way you don’t have to do unnecessary wait.
did my scripts with remote events not work?
Hello again, did you manage to fix the problem yet?
Partially.
I not made it fully yet because of highschool work. =[