Im trying to send a table through from the server to the client using a remote event, something I do in 3 other instances which all work fine, however this one keeps giving me the following error:
This is my code:
The print works and shows the correct table as you can see in the first screenshot, the rest of the code is identitcal to what works elsewhere in my game so im really unsure as to why this error occurs specifically for this table
You didn’t actually fire the remote to a client, you have to specify firstly whom client it should fire to. It wouldn’t be the case if it was RemoteEvent:FireAllClients.
I didnt even think of that but looking at it then it could be the issue,
skinweapon is this:
and so shouldnt be the issue but skinequipped is:
which could be nil, im not sure if that would specifically break it
game.Players.PlayerAdded:Connect(function(player)
local playerData = game.ServerStorage.PlayerData:WaitForChild(player.Name)
local skininventory = playerData:WaitForChild("SkinInventory")
Skinweapon = playerData:WaitForChild("Equipped").Value
if Skinweapon == "" then Skinweapon = "M4A1" -- default weapon
task.wait(4) -- enough time for items to load in
Skinselected = skininventory:FindFirstChild(Skinweapon.."Equipped").Value -- finds the value of the skin for the weapon you have equipped
--^ skinselected selects the skin which is currently equipped to the weapon which is equipped
print("skin selected from load = "..Skinselected)
local skinequipped = playerData.SkinInventory[Skinweapon.."Equipped"].Value
local Inventory1Owned = {}
for _, Item in ipairs(skininventory:GetChildren())do
local clientItem = Item:Clone()
clientItem.Parent = rs.OwnedSkins[player.Name] -- folder for the player
table.insert(Inventory1Owned, clientItem.Name)
end
print(Inventory1Owned)
skinselect:FireClient(Inventory1Owned, Skinweapon, skinequipped)
end
wait(2)
for i,v in pairs(game.ReplicatedStorage.OwnedSkins[player.Name]:GetChildren()) do
v:Destroy()
end
end)
This would be firing the table of inventory, the skin weapon, and skinequipped. But there isn’t a player value that it can fire to. So instead it should be:
local function Owned(player, Inventory1Owned, Skinweapon, skinequipped)
wait(3)
print(Inventory1Owned)
for i, v in pairs(Inventory1Owned) do
local WeaponExist = mainframe.skins:FindFirstChild(v)
if not WeaponExist then continue end -- Doesn't exist
WeaponExist[i].BorderSizePixel = 3
WeaponExist[i].BorderColor3 = Color3.fromRGB(0, 170, 0)
end
equipped = Skinweapon
selected = skinequipped
if equipped ~= "" and selected ~= "" then
script.Parent[equipped]:FindFirstChild(selected).BorderSizePixel = 3
script.Parent[equipped]:FindFirstChild(selected).BorderColor3 = Color3.fromRGB(255, 255, 127)
end
end
skinselect.OnClientEvent:Connect(Owned)
This script doesnt occur at all as the error occurs on the server before it can fire the event
FireClient requires a player to be targeted to send the data to as far as I’m aware. Maybe try putting "player, " in front of the parameter list in FireClient to see if that fixes anything?
Yup that seemed to fix that issue, which is strange as it doesnt occur on any other table which doesnt specify player but ends up leading to another error which ill add here rather than making a new post:
print(Inventory1Owned) -- 217
for i, v in pairs(Inventory1Owned) do -- 219
local WeaponExist = mainframe.skins:FindFirstChild(v)
if not WeaponExist then continue end -- Doesn't exist
WeaponExist[i].BorderSizePixel = 3
WeaponExist[i].BorderColor3 = Color3.fromRGB(0, 170, 0)
end
equipped = Skinweapon
selected = skinequipped
if equipped ~= "" and selected ~= "" then
script.Parent[equipped]:FindFirstChild(selected).BorderSizePixel = 3
script.Parent[equipped]:FindFirstChild(selected).BorderColor3 = Color3.fromRGB(255, 255, 127)
end
end