"Unable to cast string to bool" When sending data to the client

Hello. I know there are similar posts about this kind of thing but none have really helped me.

So I am making a gamepass gifting system and it is mostly working. I’m just trying to make it where when a player is gifted the gamepass they get a pop-up that says who gifted them the pass and a gift note the that gifter wrote

The pop-up works it’s just that when I add the code to display the information to the gift recipient it breaks. Here is a video of what is happening:

(Sorry for the watermark. I had to have it to export)

Here is my code:

Local Script inside the GUI


-- Vars
local Frame = script.Parent
local Players = game.Players

-- When Submit is pressed
Frame.Submit.MouseButton1Click:Connect(function()
	
	-- Get the recipiant and the gift note
	local Recipiant = Frame.PlayerName.Text
	
	local GiftNote = Frame.Note.Text
	
	if Recipiant ~= nil and GiftNote ~= nil then
		
		-- Send Data to Server
		game.ReplicatedStorage.GiftGamePass:FireServer(Recipiant, GiftNote)

		-- Product Info
		local MarketplaceService = game:GetService("MarketplaceService")

		local productID = 1251260706  -- Change this to your developer product ID

		local player = Players.LocalPlayer
		
		-- Prompt the perchase
		MarketplaceService:PromptProductPurchase(player, productID)
		
	end
	
end)

Server Script inside ServerScriptService


-- Vars
local Players = game.Players

local ProductID = 1251260706

local MarketPlaceService = game:GetService("MarketplaceService")

local GamepassWhiteList = require(script.Parent.GamePassWhitelist)

-- Retreave Data
game.ReplicatedStorage.GiftGamePass.OnServerEvent:Connect(function(plr, Recipiant, GiftNote)
	
	perchacer, playerToGift, Note = plr.Name, Recipiant, GiftNote
	
	print(typeof(perchacer)) -- Debugging. Can ignore
	
end)

local function processReceipt(receiptInfo)
	
	-- Check if the player exists
	local Player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
	if not Player then
		return Enum.ProductPurchaseDecision.NotProcessedYet
	end
	
	-- Check if the product bought is the gift
	if receiptInfo.ProductId == ProductID then
		
		-- Print Perchase Data
		print("Perchase Made. Perchaser: "..perchacer..", Recipiant: "..playerToGift..", Note: "..Note)
		
		-- Add player to whitelist
		table.insert(GamepassWhiteList, playerToGift)
		
		-- Print all players in whitelist (debugging)
		for i, v in pairs(GamepassWhiteList) do
			print(GamepassWhiteList[i])
		end
		
		-- Fire to recipiant. ERROR IS WITH THE "perchacer" peram
		game.ReplicatedStorage.GiftGamePass:FireClient(game.Players:FindFirstChild(playerToGift, perchacer, Note))
			
	end
	
end

-- Fire the function when a receipt is processed.
MarketPlaceService.ProcessReceipt = processReceipt

and then Local Script inside the pop-up GUI


-- Notify the Recipiant that they were gifted the gamepass
game.ReplicatedStorage.GiftGamePass.OnClientEvent:Connect(function(Perchacer, Note)
	
	-- Set the text lables to show who gifted and the gift note
	script.Parent.Note.Text = Note
	script.Parent.PlayerWhoGifted.Text = Perchacer
	
	-- Show notification
	script.Parent.Visible = true
	
end)

-- Reset GUI
script.Parent.Exit.MouseButton1Click:Connect(function()
	
	script.Parent.Note.Text = "N/A"
	script.Parent.PlayerWhoGifted.Text = "N/A"
	
	script.Parent.Visible = false
	
end)

Sorry if this is a bit confusing. I don’t know any better way to explain it.

1 Like

Quick question, Any reason you’re doing this?

game.ReplicatedStorage.GiftGamePass:FireClient(game.Players:FindFirstChild(playerToGift, perchacer, Note))

-- This part?
[game.Players:FindFirstChild]? 

I would assume this would be the correct term,

game.ReplicatedStorage.GiftGamePass:FireClient(Player, playerToGift, perchacer, Note)

Thanks, Opex.

1 Like

I’m doing that because the “playerToGift” Value is a string.

EDIT: I’m an idiot. I think I found out what the problem was. You were mostly right about the cause. I had all three perams in the FindFirstChild function instead of just “playerToGift”

Thank you very much for your help.

1 Like

No problem my man glad to be a help! :slight_smile:

3 Likes

FireClient()'s first argument should be the player instance belonging/pertaining to the client you intend to fire.