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

My simple catalog won't work with multiple items?

Asked by 5 years ago

SERVER SCRIPT:

local insert = game:GetService("InsertService")

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player, ID)
    if tonumber(ID) == nil then return end
    print(ID)
    local item = insert:LoadAsset(ID)
    local Child = item:GetChildren()[1]
    if Child:IsA("Decal") then
        Player.Character.Head.face.Texture = Child.Texture
    elseif Child:IsA("Accessory") then
        Player.Character.Humanoid:AddAccessory(Child)
    elseif Child:IsA("Shirt") then
        if Player.Character:FindFirstChildWhichIsA("Shirt") then
            Player.Character.Shirt.ShirtTemplate  = Child.ShirtTemplate
        else
            local Shirt = Instance.new("Shirt", Player.Character)
            Shirt.Name = "Shirt"
            Shirt.ShirtTemplate = Child.ShirtTemplate
        end
    elseif Child:IsA("Pants") then
        if Player.Character:FindFirstChildWhichIsA("Pants") then
            Player.Character.Pants.PantsTemplate = Child.PantsTemplate
        else
            local Pants = Instance.new("Pants", Player.Character)
            Pants.Name = "Pants"
            Pants.PantsTemplate = Child.PantsTemplate
        end
    end
end)

LOCAL SCRIPT:

script.Parent.TextButton.MouseButton1Click:Connect(function()
    for _, v in pairs(string.split(script.Parent.TextBox.Text, ",")) do
    game.ReplicatedStorage.RemoteEvent:FireServer(v)
    end
end)

Whenever I put more than 1 ID, it errors:

13:16:50.728 - Unable to cast string to int64
13:16:50.738 - Stack Begin
13:16:50.739 - Script 'Workspace.Script', Line 6
13:16:50.739 - Stack End

Answer this question