To be specific this script gives you a race for a one piece game. It works the first time, however after respawning it loads your appearance, then doesn’t do anything afterwards.
This script waits until specific modules are required, before continuing its part. It also connects characteradded the second the playeradded function runs.
In my opinion I think the bug revolves around the script assuming ‘HasAppearanceLoaded()’ returning true, after respawning even though the appearance wasn’t loaded completely.
This bug is only an appearance loading bug from what I experienced, and tested. This means the characteradded function runs every part of the code except for the part where it clears the appearance flawlessly, and loads the custom appearance.
Script:
game.Players.PlayerAdded:Connect(function(Player)
local PlayerStats
local function checkForData(Player)
if not PlayerStats["PlayerLoaded"].Value then
if not PlayerData then
repeat wait(2) until PlayerData
end
local Data = PlayerData:GetPlayerData(Player)
loadData(Data, Player, PlayerStats)
wait(2)
return Data
end
end
local Inventory
local PlayersData
local function loadPlayerStats(Character)
if not PlayerStats then
repeat wait(2) until PlayerStats
end
if not Player:HasAppearanceLoaded() then
repeat wait() print'loading appearance' until Player:HasAppearanceLoaded()
Player:ClearCharacterAppearance()
PlayersData = checkForData(Player)
else
wait(.5)
Player:ClearCharacterAppearance()
PlayersData = checkForData(Player)
end
if Character.Parent ~= workspace.Chars then
setParent(Character)
end
if not RaceSystem then
repeat wait(2) until
RaceSystem
RaceSystem:Fire(Player, Character, PlayerStats, PlayersData)
else
RaceSystem:Fire(Player, Character, PlayerStats, PlayersData)
end
if not StatManager then
repeat wait(2) print'loading statmanager' until
StatManager
StatManager:CharacterStats(Player, Character, PlayerStats, PlayersData)
else
StatManager:CharacterStats(Player, Character, PlayerStats, PlayersData)
end
if not Bounties then
repeat wait(2) until
Bounties
Bounties:connectbounty(Player, Character)
else
Bounties:connectbounty(Player, Character)
end
wait(2)
end
if Player.Character then
loadPlayerStats(Player.Character)
end
Player.CharacterAdded:Connect(function(Character)
loadPlayerStats(Character)
end)
PlayerStats = createStats(Player, {
Marine=false,
DevilFruit="None",
HasKen=false,
HasBuso=false,
HasHao=false,
Muscle=0,
InWater=false,
Crew=0,
Jailed=false,
InCombat=false,
BlockingValue=100,
Job="None",
Race="None",
PlayerLoaded=false,
Breath=100,
Hunger=100,
Sprint=false,
Revs=false,
Style="None",
FistExp=0,
SwordExp=0,
GloveColor="None",
})
Player:LoadCharacter()
end)