#help

1 messages · Page 1 of 1 (latest)

warm tartan
#

so there is a mess in my script rn so im not showing them for the moment but ill explain what i did.

I made a pickup system
Each item has a tag “pickup” and a stringvalue called “uniqueid.”
when i pick up an item, its model name and uniqueid get sent to the server and gives me the item.

When the data gets to the server, it checks if they are strings, and gives model.Name with uniqueid, example: (Data has been sent, model name is Radio and its unique id is (item_01)

Then i have a drop system. It deletes the item from my inventory and clones the item from rep to workspace (based on the name) with a random uniqueid

When i want to pick up a cloned item (the one i dropped) i get

Event fired by player, modelName='RadioTape', uniqueId='RadioTape'
Invalid arguments: modelName or uniqueId is not a string

Even if the cloned item has the pickup tag and his uniqueid, it says that the uniqueid is the same as the modelname, even if it is not.

what’s the problem there??

winged coral
warm tartan
#

everything on server side?

queen pumice
#

remote event

warm tartan
queen pumice
#

then u can pass the data from client to server

warm tartan
#

exactly

#

but i get this problem

#

the one i mentioned

#

wait ill send the script

#

5 minutes

queen pumice
#

k

warm tartan
#

{PICKUP SYSTEM} CLIENT 

local connectedModels = {}

local function connectPrompt(model)
    if connectedModels[model] then return end
    connectedModels[model] = true

    local success, clicker = pcall(function()
        return model:WaitForChild("Clicker", 2)
    end)

    if not success or not clicker or not clicker:IsA("BasePart") then
        warn("No clicker in:", model:GetFullName())
        return
    end

    local successPrompt, prompt = pcall(function()
        return clicker:WaitForChild("ProximityPrompt", 2)
    end)

    if not successPrompt or not prompt or not prompt:IsA("ProximityPrompt") then
        warn("no proximity prompt in :", model:GetFullName())
        return
    end
    
    prompt.Triggered:Connect(function()
        if model:IsDescendantOf(workspace) then
            local uniqueId = model:WaitForChild("UniqueId") 
            if uniqueId then
            print("proximity prompt activated for:", model.Name, uniqueId.Value)
            print("sending data:", model.Name, uniqueId, typeof(uniqueId), uniqueId.Value)
            itemPickupEvent:FireServer(model.Name, uniqueId.Value)
            end
        end
    end)
end

for _, model in ipairs(CollectionService:GetTagged("pickup")) do
    if model:IsA("Model") then
        connectPrompt(model)
    end
end

CollectionService:GetInstanceAddedSignal("pickup"):Connect(function(instance)
    if instance:IsA("Model") then
        connectPrompt(instance)
    end
end)

workspace.DescendantRemoving:Connect(function(instance)
    if connectedModels[instance] then
        connectedModels[instance] = nil
    end
end)```
#

{PICKUP SYSTEM} SERVER

--Pickup
itemPickupEvent.OnServerEvent:Connect(function(player, modelName, uniqueId)
    print(string.format("[DEBUG] OnServerEvent fired by %s with modelName='%s', uniqueId='%s'", player.Name, tostring(modelName), tostring(uniqueId)))

    if typeof(modelName) ~= "string" or typeof(uniqueId) ~=  "string" then
        warn("[DEBUG] Invalid arguments: modelName or uniqueId is not a string")
        return
    end 

    local model = findModelByNameAndId(modelName, uniqueId)
    if not model then
        warn(string.format("[DEBUG] Model lookup failed for Name='%s' UniqueId='%s'", modelName, uniqueId))
        return
    end

    print(string.format("[DEBUG] Valid model instance for %s received, proceeding with pickup...", modelName))

    local pickupsound = game.SoundService:WaitForChild("Pickup2")
    local inventory = playerInventories[player.UserId]
    if not inventory then
        warn(string.format("[DEBUG] No inventory found for player %s", player.Name))
        return
    end

    if #inventory < 9 then
        table.insert(inventory, modelName)
        print(string.format("[DEBUG] '%s' added to %s's inventory. New count = %d", modelName, player.Name, 

        itemPickupEvent:FireClient(player, modelName)
        textevent:FireClient(player, modelName, "Pickup")

        pickupsound:Play()

        model:Destroy()
        print(string.format("[DEBUG] Model '%s' destroyed in workspace", modelName))
    else
        print(string.format("[DEBUG] %s's inventory is full (count=%d)", player.Name, #inventory))
        textevent:FireClient(player, nil, "InvFull")
    end
end)
#

there i've asked chatgpt for debug lines

#

wait drop one too large

#

itemDropEvent.OnServerEvent:Connect(function(player, itemName, UniqueId) 
    local dropsound = game.SoundService:WaitForChild("ItemDrop")
    if typeof(itemName) ~= "string" then return end

local itemModel = ReplicatedStorage:WaitForChild(itemName)
            if itemModel then
                local clonedItem = itemModel:Clone()

                local idValue = clonedItem:FindFirstChild("UniqueId")
                if not idValue then
                    idValue = Instance.new("StringValue")
                    idValue.Name = "UniqueId"
                    idValue.Parent = clonedItem
                end
                idValue.Value = HttpService:GenerateGUID(false)

                if not clonedItem.PrimaryPart then
                    warn(itemName .. " does not have a PrimaryPart set.")
                    return
                end

                local character = player.Character
                if character and character:FindFirstChild("HumanoidRootPart") then
                    local rootPart = character.HumanoidRootPart
                    local dropPosition = rootPart.Position + (rootPart.CFrame.LookVector * 1)
                    clonedItem:SetPrimaryPartCFrame(CFrame.new(dropPosition))
                    clonedItem.Parent = game.Workspace
                    clonedItem:MakeJoints()

                    print(player.Name .. " dropped the " .. itemName .. " in the world with UniqueId=" .. idValue.Value)
                else
                    print("Player's HumanoidRootPart not found for " .. player.Name)
                end
            else
                print("No model found for item: " .. itemName)
            end
        else
            print(player.Name .. " does not have the item: " .. itemName)
        end
    end
end)

#

this not the complete one but it has the necessary informations

#

@queen pumice @winged coral

#

when i pick up the item in workspace: OnServerEvent fired by ItsFifty with modelName='RadioTape', uniqueId='item_001'

when i pickup the item after i've dropped it: OnServerEvent fired by ItsFifty with modelName='RadioTape', uniqueId='RadioTape'

analog sable
analog sable
#

assuming you assigned a uniqueId from the workspace by writing the id into the stringvalue of uniqueId

#

and that value could be different

warm tartan
#

i manually added a stringavlue with different ids for every item, and the cloned ones are randomly generated