When a player loads in I have a script to gather what they own and send it to the client to display on a gui. Even though im using :FireClient rather than FireAllClients it seems to be sending this information to everybody, so if 1 person owns the item, it displays as owned on everyones GUI
My server script looks like this:
game.Players.PlayerAdded:Connect(function(player)
local inventory1 = game.ServerStorage:WaitForChild("PlayerData"):WaitForChild(player.Name):WaitForChild("KSInventory")
wait(15) -- temp until I can find a better solution to waiting for data to load
equipped1 = inventory1:WaitForChild("KSLVL1").Value
equipped2 = inventory1:WaitForChild("KSLVL2").Value
equipped3 = inventory1:WaitForChild("KSLVL3").Value
print(equipped1, equipped2, equipped3)
wait(1)
--print("item name"..itemname)
local Inventory1Owned = {}
for _, Item in ipairs(inventory1:GetChildren())do
local clientItem = Item:Clone()
clientItem.Parent = rs.OwnedKS[player.Name] -- folder for the player
table.insert(Inventory1Owned, clientItem.Name)
end
kssearch:FireClient(player, Inventory1Owned, equipped1, equipped2, equipped3)
wait(1)
for i,v in pairs(rs.OwnedKS[player.Name]:GetChildren()) do
v:Destroy()
end
end)
the local script looks like this:
local function Owned(Inventory1Owned, equippeds1, equippeds2, equippeds3)
print(Inventory1Owned)
print(equippeds1,equippeds2,equippeds3)
for i, v in pairs(Inventory1Owned) do
local WeaponExist = KS:FindFirstChild(v)
if not WeaponExist then continue end -- Doesn't exist
WeaponExist.BorderSizePixel = 3
WeaponExist.BorderColor3 = Color3.fromRGB(0, 170, 0)
end
equipped1 = equippeds1
equipped2 = equippeds2
equipped3 = equippeds3
print(equipped1,equipped2,equipped3)
if equipped1 ~= "" then
KS:FindFirstChild(equipped1).BorderSizePixel = 3
KS:FindFirstChild(equipped1).BorderColor3 = Color3.fromRGB(255, 255, 127)
kslvl1.Image = KS:FindFirstChild(equipped1).Image
end
if equipped2 ~= "" then
KS:FindFirstChild(equipped2).BorderSizePixel = 3
KS:FindFirstChild(equipped2).BorderColor3 = Color3.fromRGB(255, 255, 127)
kslvl2.Image = KS:FindFirstChild(equipped2).Image
end
if equipped3 ~= "" then
KS:FindFirstChild(equipped3).BorderSizePixel = 3
KS:FindFirstChild(equipped3).BorderColor3 = Color3.fromRGB(255, 255, 127)
kslvl3.Image = KS:FindFirstChild(equipped3).Image
end
end
kssearch.OnClientEvent:Connect(Owned)
Im using a pretty identical script for other types of items in the game and this issue doesnt occur so any help would be appreicated