#Welding issue

10 messages · Page 1 of 1 (latest)

winter wigeon
#
function WeldItem(character, itemName)
    local item = Inventory_Item:Clone()
    item.Parent = Entities
    
    local UpperTorso = character:FindFirstChild("UpperTorso")
    
    item.CFrame = UpperTorso.CFrame * CFrame.new(0, 0, 1)
    
    local weld = Instance.new("Weld")
    weld.Part0 = UpperTorso
    weld.Part1 = item
    weld.C0 = UpperTorso.CFrame:Inverse()
    weld.C1 = item.CFrame:Inverse()
    
    weld.Parent = item
    
    item.ItemGui.ItemName.Text = itemName
    
end
#

That is the weld function, responsible for welding a block with text saying the item they are carrying

#

(it is in a module script called InventoryHandler)

#
function InventoryHandler.Obtain(player, character, item)
    WeldItem(character, item)
end
#

When this function is run, the weld item function is called

#
local InventoryHandler = 
require(game:GetService("ServerScriptService"):WaitForChild("InventoryHandler"))

game.Players.PlayerAdded:Connect(function(player)
    
    if player.Character then
        InventoryHandler.Obtain(player.Character, "Wheat")
    end
    
    player.CharacterAdded:Connect(function(character)
        InventoryHandler.Obtain(player, character, "Wheat")
    end)
end)
#

It won't work when player joins and spawns in please help

#

it just spawns into the workspace in the entities folder and doesnt even weld

#

nvm

#

it works