How do I make this ModelGiver script automatically give the player the model as soon as he spawns without touching the touchpart?

I’m using the RedRiver NVG kit made by @spite90 the player has to touch the touch part to get the model and I don’t want that I want it so that as soon as the player spawns they get the model.

	R15 = {
		Vest = "UpperTorso",
		Face = "Head",
		Helmet = "Head",
		Belt = "LowerTorso",
	},
	R6 = {
		Vest = "Torso",
		Face = "Head",
		Helmet = "Head",
		Belt = "Torso",
	}
}


local function recursive(parent,root)
	for k,v in pairs(parent:GetChildren()) do
		if v:IsA("BasePart") then
			local w = Instance.new("Weld")
			w.Part0 = root
			w.Part1 = v
			w.C1 = v.CFrame:toObjectSpace(root.CFrame)
			w.Parent = root
			v.Anchored = false
			v.CanCollide = false
		elseif v:IsA("Model") and v.Name ~= "Up" then
			recursive(v,root)
		end
	end
end



local model = script.Parent.Parent:FindFirstChildOfClass("Model")

local upnvg = model:FindFirstChild("Up")
local downnvg = model:FindFirstChild("Down")
if upnvg and downnvg then
	recursive(upnvg,upnvg.PrimaryPart)
	local nvgjoint = Instance.new("Motor6D")
	nvgjoint.Part0 = model.Middle
	nvgjoint.Part1 = upnvg.PrimaryPart
		
	local upvalue = Instance.new("CFrameValue")
	local downvalue = Instance.new("CFrameValue")
		
	upvalue.Name = "upvalue"
	downvalue.Name = "downvalue"
		
	upvalue.Value = model.Middle.CFrame:inverse()*upnvg.PrimaryPart.CFrame
	downvalue.Value = model.Middle.CFrame:inverse()*downnvg.PrimaryPart.CFrame
		
	upvalue.Parent = upnvg
	downvalue.Parent = upnvg
		
	nvgjoint.Name = "twistjoint"
	nvgjoint.C0 = upvalue.Value
	nvgjoint.Parent = upnvg
	
	downnvg:Destroy()
	
	local autoconfig = script:WaitForChild("AUTO_CONFIG"):Clone()
	autoconfig.Parent = upnvg
	
elseif upnvg or downnvg then
	print("Missing "..(not upnvg and "Up" or "Down").."NVG Model")
end	

local attachtype = model.Name

local bounced

function onTouched(hit)
	if hit.Parent:FindFirstChild("Humanoid") and not bounced then
		bounced = true
		delay(2,function()
			bounced = false
		end)
		local char = hit.Parent
		local oldmodel = char:FindFirstChild(attachtype)
		if oldmodel then
			oldmodel:Remove()
		end
		
		local g = model:Clone()
		
		recursive(g,g.Middle)
		
		local Y = Instance.new("Weld")
		Y.Part0 = char[attachpts[char.Humanoid.RigType.Name][attachtype]]
		Y.Part1 = g.Middle
		Y.Parent = Y.Part0
		
		g.Parent = char
	end
end

script.Parent.Touched:connect(onTouched)
-- 

I would wait until the character of the player loads in (either when the player joins or dies):

game.Players.PlayerAdded:Connect(function(plr: Player)
    plr.CharacterAdded:Connect(function(char: Model)
        onTouched(char.PrimaryPart)  --<<<your on touched function
    end)
end)

hi there thanks for your reply, sometimes the script works when I do a playtest in Roblox studio, and sometimes it doesn’t and I don’t know why here’s a video of me pressing ‘n’ and the NVG not working it only works when I go to the touch part and then press ‘n’ but the model is on my characters head.

heres a video

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if not player:HasAppearanceLoaded() then
			player.CharacterAppearanceLoaded:Wait()
		end
		
		--Weld the item to the player's character here.
	end)
end)

Like because the player’s character’s appearance hasn’t yet loaded before an attempt is made to weld the model to the player’s character.