FireServer values are coming out as nil

In my game, when you equip your pet, it runs through the server first for an integrity check and then marks the pet as equipped or unequipped. When the server is done, it will fire the client again and the client equips or unequips the pet. However, when FireClient(plr, true) is called from the server, it returns the player and… nil? This makes it so every equip or unequip request is treated as an unequip request. I just have no idea what is going on… Here is the code: (every unstated variable IS stated elsewhere in code)

Client:

current.Buttons.Equip.MouseButton1Click:Connect(function()
	pfev:FireServer(true, current.SelectedPet.Value)
end)

pfev.OnClientEvent:Connect(function(dog,tof)
	print(tof)
	if tof then
		pfm:AddPet(plr, string.gsub(current.SelectedPet.Value, "%d+", ""))
	else
		pfm:RemovePet(plr, string.gsub(current.SelectedPet.Value, "%d+", ""))
	end
end)

Server:

pfev.OnServerEvent:Connect(function(plr, tof, csv)
	if tof then
		if csv == current.SelectedPet.Value then
			local dogtag = Instance.new("BoolValue")
			dogtag.Name = current.SelectedPet.Value
			dogtag.Parent = plr.activepets
			pfev:FireClient(plr, true)
		else
			plr:Kick("Invalid pet equip request")
		end
	else
		--unfinished..
	end
end)

If you need more code then I will happily send. Thanks!

1 Like

You’re doing FireClient(plr, true) which sends true to player plr. You might have misunderstood that it also sends the plr to the client but it doesn’t.

So, on pfev.OnClientEvent:Connect(function(dog,tof), change the function(dog,tof) to function(tof)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.