Whats wrong with this code?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a player in a viewportframe but it doesnt work.

  2. What is the issue? Include screenshots / videos if possible!
    it says the parent doesnt exist? it says: attempt to index nil with 'Parent' when its a model and considers it as type “nil” when using typeof

  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    Changing how it gets the character (findfirstchild) but that didnt work

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local cf = CFrame.new(190.749985, 0, -206, 0, 0, 1, 0, 1, 0, -1, 0, 0)
if not game:IsLoaded() then
	game.Loaded:Wait()
end

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
wait(3)


local newc = character:Clone()
newc.Parent = script.Parent:WaitForChild("ViewportFrame")
newc:PivotTo(cf)

What is wrong?

You cant just clone a character this way.

You need to set the property Archivable to true, and then clone the character.

local cf = CFrame.new(190.749985, 0, -206, 0, 0, 1, 0, 1, 0, -1, 0, 0)
if not game:IsLoaded() then
	game.Loaded:Wait()
end

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
wait(3)

character.Archivable = true -->> Archivable Enabled
local newc = character:Clone()
character.Archivable = false --> Archivable Disabled

newc.Parent = script.Parent:WaitForChild("ViewportFrame")
newc:PivotTo(cf)

This should work.

2 Likes

OMG i forgot about the Archivable Property! tysm :wink:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.