I am making a setting where you can hide other’s pets, I currently have the hide part sorted and working fine.
When it comes to returning the pets if the player then toggles this setting again I can’t figure out the best approach to do this.
I have all player pets equipped sorted in a folder system in the workspace as seen below:
Would there be any way to somehow clone over the unchanged folder from the server over to the client? Or would there be a better approach to this?
This is my script currently (client script)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Settings = player:WaitForChild("Settings")
local showOtherPets = Settings:WaitForChild("showOtherPets")
local playerPets = workspace:WaitForChild("Player_Pets")
local othersPets = { --I was experimenting with a table to restore pets but couldn't get it working
}
if showOtherPets.Value == false then
for i,v in pairs(playerPets:GetChildren()) do
if v.Name ~= player.Name then
wait(0.1)
table.insert(othersPets,v)
v:Remove()
end
end
end
playerPets.ChildAdded:Connect(function(child)
if child.Name ~= player.Name and showOtherPets.Value == false then
wait(0.1)
table.insert(othersPets,child)
child:Remove()
end
end)
showOtherPets.Changed:Connect(function()
if showOtherPets.Value == false then
for i,v in pairs(playerPets:GetChildren()) do
if v.Name ~= player.Name then
wait(0.1)
table.insert(othersPets,v)
v:Remove()
end
end
end
end