Unable to cast value to object?

I want to know how to fix this issue.
I am getting an “Unable to cast value to object” error when trying to invokeclient via an remotefunction.
https://gyazo.com/9585c5081d60c61155b57be32ccff07e
I don’t have any idea how to fix it, it’s not like a remote event so…

Script invoking client

local Template = {
	["Kills"] = 0,
	["Nickname"] = {},
	["Deaths"] = 0,
	["Banned"] = false,
	["Warnings"] = 0
}
local banned = script.Parent.Banned.Value
local Deaths = script.Parent.Deaths.Value
local Kills = script.Parent.Kills.Value
local Nickname = script.Parent.Nickname.Value
local Warns = script.Parent.Warnings.Value
local char = script.Parent.Parent
while wait(1) do
	if char.Humanoid.Health == 0 then
		Deaths = Deaths + 1
	end
	local fem = game.ReplicatedStorage.SaveHandlerToClient
	Template.Kills = Kills
	table.insert(Template.Nickname,Nickname)
	table.remove(Template.Nickname,1)
	Template.Deaths = Deaths
	Template.Banned = banned
	Template.Warnings = Warns
	fem:InvokeClient('Save',Template)
end

Local script Handling it.

local Data = {
	["Kills"] = 0,
	["Nickname"] = {""},
	["Deaths"] = 0,
	["Banned"] = false,
	["Warnings"] = 0
}
local killc = 0
local rem = game.ReplicatedStorage.DataHandler
wait(3)
local z = rem:InvokeServer('Load',nil,true)
killc = z.Kills
script.Parent.Text = 'Kills: '..killc
local function handle(playa,typeofthing,tabl)
	if typeofthing == 'Save' then
		rem:InvokeServer('Save',tabl,true)
	elseif typeofthing == 'Load' then
		return rem:InvokeServer('Load',nil,true)
	end
end
local savehand = game.ReplicatedStorage.SaveHandlerToClient
savehand.OnClientInvoke = handle
2 Likes

You need to pass the player as the first argument when calling InvokeClient, as you need to define WHICH client you want to fetch the information from.

    local Player = game:GetService("Players"):GetPlayerFromCharacter(char)
	fem:InvokeClient(Player, 'Save',Template)
1 Like