Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RS = Game:GetService('ReplicatedStorage')
- local Players = Game:GetService('Players')
- local Timer = require(RS.Timer)
- local Scheduler = require(RS.Scheduler)
- local CustomCharacter = require(RS.CustomCharacter)
- local CustomCharacterView = require(RS.CustomCharacterView)
- local Player = Players.LocalPlayer
- -- Keep this script running for the whole session
- Scheduler:FastWait()
- script.Parent = nil
- Game:GetService('StarterGui').ResetPlayerGuiOnSpawn = false
- local PartsToHide = {['Head'] = true; ['Torso'] = true; ['Right Leg'] = true, ['Left Leg'] = true, ['Right Arm'] = true, ['Left Arm'] = true}
- local function handleCharacter(player, character)
- -- Make the existing character invisible
- function handleChild(p)
- if p:IsA('BasePart') and PartsToHide[p.Name] then
- p.Transparency = 1
- end
- if p:IsA('Shirt') or p:IsA('Hat') then
- Spawn(function()
- p:Destroy()
- end)
- end
- if p.Name == 'Head' then
- for _, ch in pairs(p:GetChildren()) do
- if ch:IsA('Decal') then Spawn(function() ch:Destroy() end) end
- end
- end
- end
- for _, part in pairs(character:GetChildren()) do
- handleChild(part)
- end
- character.ChildAdded:connect(handleChild)
- -- Create a view
- local customCharacter = CustomCharacter.CreateDefault(character)
- local customCharacterView = CustomCharacterView.Create(customCharacter, character)
- -- Main loop
- local timer = Timer.Create()
- while character.Parent do
- local animateTimer = Timer.Create()
- customCharacterView:Update(timer:GetDelta())
- --print(string.format("%3.2fms", animateTimer:GetDelta()*1000))
- Scheduler:FastWait()
- end
- customCharacterView:Destroy()
- end
- local function handlePlayer(player)
- if not player:IsA('Player') then return end
- player.CharacterAdded:connect(function(character)
- handleCharacter(player, character)
- end)
- if player.Character then
- Scheduler:FastSpawn(handleCharacter, player, player.Character)
- end
- end
- Players.ChildAdded:connect(handlePlayer)
- for _, player in pairs(Players:GetChildren()) do
- if player:IsA('Player') then
- Scheduler:FastSpawn(handlePlayer, player)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement