I'm trying to make a game like one on the Wii game : Wii play and I want to make it where right as the player joins the game or when they touch a brick, it causes a clone of that player to spawn in a specific location. Thanks for any help, I'm extremely new to scripting!
COMMUNITY QUESTION
How do I clone the local players avatar right as they join?
1 answer
You must use the PlayerAdded event. This code will run when a player joins the game. Make sure it's a ServerScript (Regular Script) inside ServerScriptStorage.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
repeat
wait()
until
player.Character -- Waits until the player's character has loaded.
local clone = player.Character:Clone() -- Cloned Character.
clone:MoveTo(workspace.Part.Position) -- Change workspace.Part to the part you want it to teleport to.
clone.Parent = workspace
end)
The code below is for a brick that you touch. This uses a debounce so that the character won't spam appear. Make sure you put it inside the part you want the player to hit and make it a ServerScript (Regular Script).
local Players = game:GetService("Players")
local debounce = false
script.Parent.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent) -- Gets the player from it's character.
if player and not debounce then -- Checks if the part it hit is a player.
debounce = true
local clone = player.Character:Clone()
clone:MoveTo(player.Character:WaitForChild("HumanoidRootPart").Position)
clone.Parent = workspace
wait(2)
debounce = false
end
end)
Also, this is supposed to be a help website for scripts that you have already made, not a request website.
1 comment
0
Make sure that you turn on Archivable for the player's character, otherwise you won't be able to clone it
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I saw that you commented on my answer. Did you need help with anything?