Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Attempt to concatenate local "Item"( a userdata value) how do I fix that?

Asked by 6 years ago

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
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. User#21908 42 — 6y
1
Assuming Object.Value is the Value property of an ObjectValue, you will need to concatenate the name, not the object itself. User#24403 69 — 6y
0
Also note that Player is not a parameter of the MouseButton1Click event. User#21908 42 — 6y
1
Additionally, Player is nil since MouseButton1Click passes nothing, not even a player. User#24403 69 — 6y
View all comments (2 more)
0
Use LocalPlayer. User#21908 42 — 6y
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?. User#24403 69 — 6y

Answer this question