-
Notifications
You must be signed in to change notification settings - Fork 44
/
CharacterTester.lua
40 lines (32 loc) · 972 Bytes
/
CharacterTester.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
local CharacterTester = {}
local StarterPlayer = game:GetService("StarterPlayer")
local function removeExistingStarterCharacter()
while true do
local starterCharacter = StarterPlayer:FindFirstChild("StarterCharacter")
if starterCharacter then
starterCharacter:Destroy()
else
break
end
end
end
local function addAccessoriesFromWorkspace(character)
-- Clone accessories into character
for _, accessory in pairs(game.Workspace:GetChildren()) do
if accessory:IsA("Accessory") then
local newAccessory = accessory:Clone()
newAccessory.Parent = character
end
end
end
function CharacterTester.SetupCharacterForTesting(characterToTest)
if not characterToTest then
return
end
removeExistingStarterCharacter()
local newCharacter = characterToTest:Clone()
addAccessoriesFromWorkspace(newCharacter)
newCharacter.Name = "StarterCharacter"
newCharacter.Parent = StarterPlayer
end
return CharacterTester