RemoteEvent firing to all clients rather than the local?

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

Is that local script shared by all clients? And where is the RemoteEvent ‘kssearch’ located?

The local script is inside a gui, so should be unique to each player while the remotevent is stored in replicatedstorage

kssearch:FireClient(player, Inventory1Owned, equipped1, equipped2, equipped3)

This line of code is executed for each player, considering its presence inside of a function connected to ‘PlayerAdded’.

Isnt it supposed to do that? When a player joins, get their data and send it to their client rather than get 1 players data and send it to all the clients

Try making your equipped variables local perhaps.

1 Like