Server side has Part which has IntValue
Part → State
‘State’ is IntValue. The server change this value
The server listens for the ‘Touched’ event from the Part
The client listens for the ‘Change’ event of ‘State’ value and create Model depending on it.
The ‘State’ variable mimics the stages of plant growth.
Depending on the growth of the plant and if the player touches the block, the value of the variable changes
So there are many the same Parts and many players.
Sometimes the ‘State’ variable is not replicated.
Can I trust IntValue?
How can this problem be solved?
It would be cleaner and safer from exploitation to have the server keep track of the part’s state in a script hidden from the player, and use Remote Events to tell the relevant players to do whatever it is when the state should change
With your system it sounds like you’re having to pool every Part and create an event bound to its State.Changed event, and somewhere in that you’re losing a reference, or the Part is now nil (unsure of your verbiage “not replicated”)
IntValue is not replicated to server side.
You have the server altering State’s .Value, so it has to be replicated between client and server.
The event may also not reach the client.
Only in a situation where a thread is hanging might a Remote Event not reach a client, this shouldn’t be a reason to avoid using them
Where could I lose the reference or have a nil value?
-- local script
local function addEvent(part)
local state = part:WaitForChild("State")
state.Changed:Connect(function(value)
-- change the model
end)
end
local folder = game.Workspace -- for example
local children = folder:GetChildren()
for i = 1, #children do
addEvent(children[i])
end
folder.ChildAdded:Connect(addEvent)