I want to make a script that will help me change people into a char when they join the game. This one is not working. Put this as a script.
01 | function Intialize(character) |
02 | for i, child in pairs (script:GetChildren()) do |
03 | if child.className = = "Script" or child.className = = "LocalScript" then |
04 | local c = child:Clone() |
05 | c.Parent = character |
06 | c.Disabled = false |
07 | end |
08 | end |
09 | end |
10 |
11 | function Apply(obj) |
12 | if obj.className = = "Humanoid" and obj.Health > 0 and obj.MaxHealth > 0 then |
13 | Intialize(obj.Parent) |
14 | end |
15 | for i, child in pairs (obj:GetChildren()) do |
Put this inside that script as a regular script.
01 | wait() |
02 |
03 | ch = script.Parent |
04 | set = game.Workspace --This MUST be the original area. |
05 | id = "Alar Knight of Splintered Skies" --Do NOT Mess with it!!! Leave the next 14 lines alone. |
06 | parts = { "Right Arm" , "Left Arm" , "Right Leg" , "Left Leg" , "Torso" , "hats" } |
07 | names = { "ra" , "la" , "rl" , "ll" , "ts" , "ht" } |
08 |
09 | wait() |
10 |
11 | function CloneMesh(name) |
12 | local child = set:FindFirstChild(id .. " " .. name) |
13 | local result = nil |
14 | if child ~ = nil and child.className = = "CharacterMesh" then --Leave alone. Must be "CharacterMesh" |
15 | result = child:Clone() |
Any output? Also I'm not sure but when a Player respawns in a game, their character model never disappears so. If I were you I would try something like.
01 | function Respawn(prop,player) |
02 | if prop = = "Character" then |
03 | initialize(player) |
04 | end |
05 | end |
06 |
07 | game.Players.PlayerAdded:( function (player) |
08 | initialize(player) |
09 | player.Changed:connect( function (prop) Respawn(prop,player)) |
10 | end ) |
It's always easier working from the player than the character because the character is removed and beaten up all the time. The player is a constant object.