For context I am creating a 2 player obby and each player is assigned a colour, they can only stand on platforms that match their colour. To convey this to the players I have made a system that makes all parts of the opposite colour slightly transparent.
However this system only applies this to all parts that are currently within the players render distance meaning after they progress through the obby, the parts that were not previously loaded will be loaded and are not transparent.
I have attempted to send all the parts from the server using a remote function, however parts that are not loaded in either don’t show up or appear as “nil”
I haven’t been able to find any forums about this so I decided to make a post. I would want to make a system that sets the transparency of the parts as they load in but I don’t know of the best way to do that
client side scripts
Initial Client-Side method
local blueCollisionParts = game.Workspace.BlueCollisionParts:GetChildren()
local redCollisionParts = game.Workspace.RedCollisionParts:GetChildren()
local function SetTransparency(plrNum)
--Fetching parts from server
local blueCollisionParts = GetColouredParts:InvokeServer("Blue")
local redCollisionParts = GetColouredParts:InvokeServer("Red")
print(redCollisionParts, #redCollisionParts ,blueCollisionParts , #blueCollisionParts)
if plrNum == 1 then
for i = 1, #blueCollisionParts do
blueCollisionParts[i].Transparency = 0.4
end
for i = 1, #redCollisionParts do
redCollisionParts[i].Transparency = 0
end
else
for i = 1, #redCollisionParts do
redCollisionParts[i].Transparency = 0.4
end
for i = 1, #blueCollisionParts do
blueCollisionParts[i].Transparency = 0
end
end
end
SetTransparencyEvent.OnClientEvent:Connect(SetTransparency)
server side script
local redParts = game.Workspace.RedCollisionParts:GetChildren()
local blueParts = game.Workspace.BlueCollisionParts:GetChildren()
local GetColouredParts = game.ReplicatedStorage.RemoteEvents.GetColouredParts
local function sendColouredParts(plr, colour)
print(colour)
if colour == "Blue" then
return blueParts
elseif colour == "Red" then
return redParts
end
end
GetColouredParts.OnServerInvoke = sendColouredParts