Unable to get the String of a Value

Hello. :wave:

I’m trying to send a log message for a hand-to system for tools, using a Discord webhook, but it won’t allow me to use values inside of the content of what it should send, and is coming up with an error. Any help on how to fix this would be appreciated, thanks! :heart:

local HandtoEvent = game.ReplicatedStorage.HandtoEvent
local ConfirmHandtoEvent = game.ReplicatedStorage.ConfirmHandtoEvent

HandtoEvent.OnServerEvent:Connect(function(Player, NameOfPlayerToGive)
	local PlayerToGive = game.Players:FindFirstChild(NameOfPlayerToGive)

	local Character = Player.Character
	local CurrentlyEquippedTool = Character:FindFirstChildWhichIsA("Tool")

	local ConfirmGUI = PlayerToGive.PlayerGui.ConfirmGUI

	if CurrentlyEquippedTool.Name == "Magic" then
		ConfirmGUI.Enabled = false
	else
		if CurrentlyEquippedTool.Name == "GravityCoil" then
			ConfirmGUI.Enabled = false
		else
			if CurrentlyEquippedTool.Name == "SpeedCoil" then
				ConfirmGUI.Enabled = false
			else
				if CurrentlyEquippedTool.Name == "ManagementWacker" then
					ConfirmGUI.Enabled = false
				else
					if CurrentlyEquippedTool.Name == "Mop" then
						ConfirmGUI.Enabled = false
					else
						if CurrentlyEquippedTool.Name == "Gold" then
							ConfirmGUI.Enabled = false
						else
							if CurrentlyEquippedTool.Name == "GoldCupcake" then
								ConfirmGUI.Enabled = false
							else
								ConfirmGUI.Enabled = true
								print(ConfirmGUI.Enabled)
								ConfirmGUI.BackFrame.ConfirmText.Text = Player.Name .. " is handing you a " .. CurrentlyEquippedTool.Name .. ". Would you like to accept?"

								ConfirmGUI.PlayerWhoGaveItem.Value = Player.Name
								ConfirmGUI.ItemThatWasGiven.Value = CurrentlyEquippedTool

								CurrentlyEquippedTool.Parent = ConfirmGUI
							end
						end
					end
				end		
			end
		end
	end
end)

ConfirmHandtoEvent.OnServerEvent:Connect(function(Player, Confirm)
	local ConfirmGUI = Player.PlayerGui.ConfirmGUI
	local NameOfPlayerWhoGaveItem = ConfirmGUI:WaitForChild("PlayerWhoGaveItem").Value
	local ItemThatWasGiven = ConfirmGUI:WaitForChild("ItemThatWasGiven").Value

	if Confirm == true then
		ItemThatWasGiven.Parent = Player:WaitForChild("Backpack")
		game.Players[NameOfPlayerWhoGaveItem].leaderstats.Points.Value = game.Players[NameOfPlayerWhoGaveItem].leaderstats.Points.Value + 1
		local http = game:GetService("HttpService")
		local Data = {
			["content"] = Player.Name..NameOfPlayerWhoGaveItem..ItemThatWasGiven
		}

		Data = http:JSONEncode(Data)

		http:PostAsync("webhookurl", Data)
		ConfirmGUI.PlayerWhoGaveItem.Value = ""
		ConfirmGUI.ItemThatWasGiven.Value = nil
	else
		ItemThatWasGiven.Parent = game.Players[NameOfPlayerWhoGaveItem].Backpack
	end
	ConfirmGUI.Enabled = false
end)

Did you mean ItemThatWasGiven.Name?

That simply returns the Name, “ItemWasGiven” as it’s returning the name of the IntValue.

image
image

ItemThatWasGiven is an object Value. You can’t concatenate an object value like that because you’re referencing an instance (the object’s value’s value is an instance). So instead, use tostring(ItemThatWasGiven) to convert it to a string.

I suggest trying

Player.Name..NameOfPlayerWhoGaveItem.Value.Name..ItemThatWasGiven.Value.Name

Since the objects in question are ObjectValues, their ‘Value’ is a reference to another instance. So, by grabbing the name of the referenced value, you will be concatenating all string values. Forgive me if I’m misinterpreting the purpose of the line.

3 Likes