This script works 99% of the time, but the 1% is a chance that it doesn’t run the function at all and doesn’t give the player the shirt/pants, and it wont even clear the appearance of the character.
What is wrong with this script?
local admins = {
[409522146] = "Dracolyx",
}
_G.connectFunctions = {}
game.Players.PlayerAdded:Connect(function(player)
local Wins = Instance.new("IntValue",player)
Wins.Name = "Wins"
local Loss = Instance.new("IntValue",player)
Loss.Name = "Losses"
player.Chatted:Connect(function(msg)
if player.Character and player.Character:FindFirstChild("Ball") == nil then
if string.lower(msg) == "ball" then
if admins[player.userId] then
local Ball = game.ServerStorage.Ball:Clone()
Ball.Parent = workspace
Ball.CFrame = player.Character.HumanoidRootPart.CFrame
end
elseif string.lower(msg) == "clean" and admins[player.userId] then
for _,part in pairs(workspace:GetChildren()) do
if part.Name == "Ball" then
part:Destroy()
end
end
end
end
end)
player.CharacterAppearanceLoaded:Connect(function(Character)
player:ClearCharacterAppearance()
script:WaitForChild("RecordGUI"):Clone().Parent = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
local Default = script.PlayerColor:Clone()
Default.Parent = Character
local Shirt = script.DefaultShirt:Clone()
local Pants = script.DefaultPants:Clone()
Shirt.Parent = Character
Pants.Parent = Character
local Head = Character:WaitForChild("Head")
local face = Head:FindFirstChild("face") or Head:FindFirstChild("Face")
if face then face:Destroy() end
local DefaultFace = script.DefaultFace:Clone()
DefaultFace.Parent = Head
Humanoid.Died:Connect(function()
player:Kick("You exploiting?")
end)
end)
end)