ViewportFrame isn't working

I’m not sure why this isn’t working…

Local script code…

for i, v in pairs(KnifesTable:GetChildren()) do
	print(v.Name)
	print(tostring(i))
	if v.Value == 0 then 
		print("nothing lol")
		return
	else
		warn("yesssir!")
	end

	print("Started!")

	print("one done")
	local tem = template:Clone()
	tem.Visible = true
	local label = tem.TextLabel
	tem.Parent = script.Parent
	label.Text = v.Name .. " x" .. v.Value
	
	local vpf = Instance.new("ViewportFrame", tem)

	local weapon = game.ReplicatedStorage.Knifes:FindFirstChild(v.Name)
	
	if weapon then
		print("yes there is weapon")
		print(weapon.Name .. " iss a thing!!")
	end

	local clone = weapon.Handle:Clone()
	clone.Parent = vpf

	clone.Anchored = true

	local cam = Instance.new("Camera")
	cam.Parent = vpf

	cam.CFrame = CFrame.new(clone.Position + Vector3.new(0, 0, 3), clone.Position)

	vpf.CurrentCamera = cam
	
	if vpf then
		print("vpf is a thing")
		print(vpf.Parent.Name)
	else
		print("nope")
	end
	
	tem.MouseButton1Down:Connect(function()
		game.ReplicatedStorage.SelectKnife:FireServer(v)
	end)

	v.Changed:Connect(function()
		tem.Text = v.Name .. " x" .. v.Value
	end)
end

Output

  Clown  -  Client - TemCopier:9
  15:09:33.895  1  -  Client - TemCopier:10
  15:09:33.896  yesssir!  -  Client - TemCopier:15
  15:09:33.896  Started!  -  Client - TemCopier:18
  15:09:33.896  one done  -  Client - TemCopier:20
  15:09:33.896  yes there is weapon  -  Client - TemCopier:32
  15:09:33.897  Clown iss a thing!!  -  Client - TemCopier:33
  15:09:33.897  vpf is a thing  -  Client - TemCopier:49
  15:09:33.897  Template  -  Client - TemCopier:50

Screenshots:
image


image

image
That’s a lot of screenshots…

1 Like