So I am working on a game that has a cutscene at the beginning. I made a script that waits for your character to load, then duplicates your character and puts it in a specific position. Then, when the cutscene happens, it shows your character.
This script works, but since it is a Server Script, if more than 1 person is playing the game, it will duplicate Both of your characters, causing it to look weird.
Here is the Server Script:
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() local char = player.Character char.Archivable = true local newPlayer = char:Clone() newPlayer.Name = player.Name .. "Clone1" newPlayer.Parent = game.Workspace char.Archivable = false local foundShirt = player.Character:WaitForChild("Shirt") local foundPants = player.Character:WaitForChild("Pants") if not foundShirt then print("Could not find Player Shirt") local newShirt = Instance.new("Shirt", newPlayer) newShirt.Name = "Shirt" newShirt.ShirtTemplate = "http://www.roblox.com/asset/?id=8222415167" else if foundShirt then print("Player Shirt Found. Duplicating for Clone...") local shirtCloned = Instance.new("Shirt") shirtCloned.ShirtTemplate = foundShirt.ShirtTemplate shirtCloned.Parent = newPlayer shirtCloned.Name = "Shirt" end end wait(0.5) if not foundPants then print("No Pants Found. Creating Default Replacement Pants...") local newPants = Instance.new("Pants", newPlayer) newPants.Name = "Pants" newPants.PantsTemplate = "http://www.roblox.com/asset/?id=6476430965" else if foundPants then print("Pants Found. Duplicating for Clone...") local pantsCloned = Instance.new("Pants") pantsCloned.PantsTemplate = foundPants.PantsTemplate pantsCloned.Parent = newPlayer pantsCloned.Name = "Shirt" end end print("Successfully cloned or replaced Player Clothing. Moving on with the script...") wait(0.5) newPlayer.Head:Destroy() wait(1) newPlayer.UpperTorso.Anchored = true newPlayer.UpperTorso.CFrame = CFrame.new(2.992, 3.696, -586.644) newPlayer.UpperTorso.Orientation = Vector3.new(90, 180, 0) newPlayer.LowerTorso.CFrame = CFrame.new(2.992, 3.696, -585.644) newPlayer.LowerTorso.Anchored = true newPlayer.LowerTorso.Orientation = Vector3.new(90, 180, 0) newPlayer.RightUpperArm.CFrame = CFrame.new(1.358, 3.696, -586.806) newPlayer.RightUpperArm.Anchored = true newPlayer.RightUpperArm.Orientation = Vector3.new(90, 155, 0) newPlayer.RightLowerArm.CFrame = CFrame.new(1.107, 3.696, -586.269) newPlayer.RightLowerArm.Anchored = true newPlayer.RightLowerArm.Orientation = Vector3.new(90, 155, 0) newPlayer.RightHand.CFrame = CFrame.new(0.843, 3.696, -585.702) newPlayer.RightHand.Anchored = true newPlayer.RightHand.Orientation = Vector3.new(90, 155, 0) newPlayer.LeftUpperArm.CFrame = CFrame.new(4.714, 3.696, -586.718) newPlayer.LeftUpperArm.Anchored = true newPlayer.LeftUpperArm.Orientation = Vector3.new(90, -150, 0) newPlayer.LeftLowerArm.CFrame = CFrame.new(5.01, 3.696, -586.205) newPlayer.LeftLowerArm.Anchored = true newPlayer.LeftLowerArm.Orientation = Vector3.new(90, -150, 0) newPlayer.LeftHand.CFrame = CFrame.new(5.323, 3.696, -585.663) newPlayer.LeftHand.Anchored = true newPlayer.LeftHand.Orientation = Vector3.new(90, -150, 0) newPlayer.RightUpperLeg.CFrame = CFrame.new(2.492, 3.696, -585.023) newPlayer.RightUpperLeg.Anchored = true newPlayer.RightUpperLeg.Orientation = Vector3.new(90, 180, 0) newPlayer.RightLowerLeg.CFrame = CFrame.new(2.492, 3.696, -584.243) newPlayer.RightLowerLeg.Anchored = true newPlayer.RightLowerLeg.Orientation = Vector3.new(90, 180, 0) newPlayer.RightFoot.CFrame = CFrame.new(2.492, 3.696, -583.594) newPlayer.RightFoot.Anchored = true newPlayer.RightFoot.Orientation = Vector3.new(90, 180, 0) newPlayer.LeftUpperLeg.CFrame = CFrame.new(3.492, 3.696, -585.023) newPlayer.LeftUpperLeg.Anchored = true newPlayer.LeftUpperLeg.Orientation = Vector3.new(90, 180, 0) newPlayer.LeftLowerLeg.CFrame = CFrame.new(3.492, 3.696, -584.243) newPlayer.LeftLowerLeg.Anchored = true newPlayer.LeftLowerLeg.Orientation = Vector3.new(90, 180, 0) newPlayer.LeftFoot.CFrame = CFrame.new(3.492, 3.696, -583.594) newPlayer.LeftFoot.Anchored = true newPlayer.LeftFoot.Orientation = Vector3.new(90, 180, 0) newPlayer.HumanoidRootPart.Anchored = true newPlayer.HumanoidRootPart.CFrame = CFrame.new(3.078, 3.696, -586.444) newPlayer.HumanoidRootPart.Orientation = Vector3.new(90, 180, 0) wait(1) print("Finished Duplicating Player for Cutscene.") end) end)
How would I make it so it only shows your character, and duplicates your character instead of duplicating and showing everybody's character at one time?
Use a LocalScript to clone the players character, that way only the client will see his own character
Tho, if you don't wanna do that, you can clone all players characters in the server, then make a LocalScript that deletes all clones except the LocalPlayer's clone