Client Remote Event = (string expected, got Instance)

Hello, so I’m making my very own killfeed which sends the name of the killer, victim and the image of the tool used. Everything seems fine but it won’t get the string from an instance. It gives me an error (string expected, got Instance). I don’t know what I’m doing wrong.

Character Script (Can also be used to a player’s avatar or NPC)

KillFeedActivate = game.ReplicatedStorage.Remotes.KillFeedActivate

local Humanoid = script.Parent.Humanoid
function Killed() 
local tag = Humanoid:findFirstChild("creator") 
if tag ~= nil then 
if tag.Value ~= nil then 
	
			local killer = tag.Value
			local victim = script.Parent.Name
			local killertool

			
			for i, tool in pairs(tag.Value.Character:GetChildren()) do
				if tool:IsA("Tool") then
					killertool = tool.toolName.Value		
				end
			end 
			
			KillFeedActivate:FireAllClients(killer,victim,killertool)
			
script:remove() 
end 
end 
end 

Humanoid.Died:connect(Killed)

Player Localscript:

KillFeedActivate = game.ReplicatedStorage.Remotes.KillFeedActivate


local player = game.Players.LocalPlayer

function KillFeed(killer,victim,killertool)
	
	local newkillfeed = game.ReplicatedStorage.KillFeed.Info:Clone()
	
	print (killer,killertool,victim) 
-- It successfully prints like this ("joshjosh170 rbxassetid://9011215570 Dummy")

--This is where my problem starts.	
	newkillfeed.Killer.Text = killer
	newkillfeed.Tool.Image = killertool
	newkillfeed.Victim.Text = victim
--Gives an error "invalid argument #3 (string expected, got Instance)"

	newkillfeed.Parent = player.PlayerGui.KillFeedGui.List
end

Make sure you provide matching variables. For e.g: 1st in FireAllClients is always the players( automatically) Now, you need to see if the others you put- are not identified as instances(objects), but as stings( in this case).

Are you sure Tag is a String and not an object? It will print the same either way, so I would investigate that.

May I ask why you are:

  1. Using :Remove()
  2. Destroying the script?
2 Likes

Thank you, after some experiments. The problem only occurs on the killer. It seems like it doesn’t accept killer = tag.Value. The victim’s name and tool’s image ID works.

1 Like

As @ifkpop said here, make sure the tag.Value is a string and not an object. Man Ive reached my 1st day limit of replying.

1 Like

It destroys the script after firing when a player or NPC dies. It was already added because of some previous tests.

I forgot to mention this in my initial question, however :remove() has been deprecated. You should use :Destroy() instead.

Usually there is a more elegant solution than destroying scripts, however I’m sure you have your reasons. Either way that’s not the issue, check if the tag.Value is a string or an object, if it is an object you may want to send it’s name instead.

1 Like

Yeah, you’re correct. I got it now. I added “local killer = tag.Value.Name” to the character script and it’s now working fine. Thank you! :smiley:

1 Like

If this is the old tagging system Roblox used to use in its own gears/brickbattle tools then the tag’s value points to the killer’s character model.