Hello there! I press my shop button buy then this happens in the output: Attempt to concatenate local "Item"( a userdata value)

How do I fix it I have 2 Script one script and one local they are these:

Local:

script.Parent.Parent.Changed:Connect(function()
	print("TEXTED")
	local Item = script.Parent.Parent.Parent.Item
	if Item.Value == 1 then
		print("djsjsdj")
		local TextStart = workspace.Shop.StoneHolder.Stone.Object.Value
	    local TextMiddle = workspace.Shop.StoneHolder.Stone.Price.Value
	    local TextFin = "Buy "..TextStart.." - "..TextMiddle
	    script.Parent.Text = TextFin
	    print(script.Parent.Text)
	    print(TextFin)
	end
end)

local Stone = workspace.Shop.StoneHolder.Stone
local StoneBought = Stone.Bought
script.Parent.MouseButton1Click:Connect(function(Player)
	if StoneBought.Value == false then
		local Repliacted = game.ReplicatedStorage
		local Item = "Stone"
		Repliacted.DataHandler:InvokeServer(Player,Item)
		StoneBought.Value = true
	end
end)

And the script:

game.ReplicatedStorage.DataHandler.OnServerInvoke = function(Player,Item)
	print(Item)
	local Shop = workspace.Shop
	local Holder = Shop:FindFirstChild(Item.."Holder")
	local ItemToBuy = Holder.Item
	local Price = Item.Price
	local Tea = Player.leaderstats.Tea
	print(ItemToBuy)
	local Clone = game.ReplicatedStorage.Item:Clone()
	Clone.Parent = Player.Backpack
end

6 comments

0

The reason this error is popping up is because Player is not an argument you need to provide from the client. What is happening is that you are providing player as an argument to the Item parameter.

1

Assuming Object.Value is the Value property of an ObjectValue, you will need to concatenate the name, not the object itself.

0

Also note that Player is not a parameter of the MouseButton1Click event.

1

Additionally, Player is nil since MouseButton1Click passes nothing, not even a player.

0

Use LocalPlayer.

1

Also you aren't returning any values from the RemoteFunction, you might want to use a RemoteEvent instead. And this isn't really answerable since there isn't much information. What is "Object.Value"? What is "Price.Value"? What line do you get the error on?.