Can you tell me whats wrong with line 6?

Theres still a nil in it image

try this :

local player = game.Players.LocalPlayer
local nameofplayer = player.Name
local char = workspace:FindFirstChild(player.Name)

script.Parent.MouseButton1Click:Connect(function()
if char~=nil then
      local really = char:Clone()
      really.Parent = game.Workspace
      really.Position = Vector3.new(11, 0.5, 10)
end
end)

Char would be nil, because you didn’t wait for the character.

1 Like

Still my Variable really is nil image

1 Like

try this

script.Parent.MouseButton1Click:Connect(function()
    local character = game.Players.LocalPlayer.Character
    if character then
        local really = character:Clone()
        really.Parent = workspace
        really:SetPrimaryPartCFrame(CFrame.new(11, 0.5, 10))
    end
end)
1 Like

The cloned value will always be nil due to the fact that every player’s character has the property of Archivable set to false.

script.Parent.MouseButton1Click:Connect(function()
    local character = game.Players.LocalPlayer.Character
    if character then
        character.Archivable = true
        local really = character:Clone()
        really.Parent = workspace
        really:SetPrimaryPartCFrame(CFrame.new(11, 0.5, 10))
    end
end)

Possibly try that.

5 Likes

OMG dude thanks so much

2 Likes

try to change game.Players.LocalPlayer to script.Parent.Parent.Parent.Name

A replication of either:

Client-sided only

  • LocalScript
  • UI calling function to clone your character
  • Character duplicates with also LocalScript controls

Server-sided

  • LocalScript & Script
  • UI firing remotes to clone character
  • Character modified to the control scripts for server
1 Like
local player = game:GetService("Players").LocalPlayer
local char = player.Character

script.Parent.MouseButton1Click:Connect(function()
    local really = char:Clone()
    really.Parent = workspace
    really.Position = Vector3.new(11, .5, 10)
end)

I’ll walk through why your original code won’t work:

  • You are trying to get the player but instead referencing the name, this just won’t work.
  • When you clone the player in your event, you are trying to clone a string. The :Clone() method only works on instances, not strings.

Apart from that everything looks fine.

2 Likes

Also I have a question, is there a way to make the position where a part is located. Like if that part moves it still gets the position and clone there?

I think you’re looking for something that has to do with relative positions. However, it is more suitable if you created another topic as discussing this will derail it from the current topic.

Archivable is also a problem with the original code. Instances with Archivable on will return nil when the Clone method is used with them.

2 Likes