hello, i made a script a while ago that turns the player body parts into a forcefield and then back to normal, work just fine in studio but makes me invisible in the actual game, why???
here’s the code, It was working before but now its broken
local Players = game:GetService("Players")
local function onCharacterAdded(character)
local SavedColorTable = {}
local enabled = false
for i,Child in pairs (character:GetChildren()) do
if Child:IsA("BasePart") then
SavedColorTable[Child.Name] = Child.Color
print(SavedColorTable)
end
end
task.wait(0.5)
for i,Child in pairs (character:GetChildren()) do
if Child:IsA("BasePart") then
Child.Color = Color3.fromRGB(255, 255, 255)
Child.Material = 'ForceField'
end
end
task.wait(0)
for i,Child in pairs (character:GetChildren()) do
if Child:IsA("Accessory") then
local ChildA = Child:FindFirstChildWhichIsA("Part")
ChildA.Color = Color3.fromRGB(255, 255, 255)
ChildA.Material = 'ForceField'
end
end
task.wait(3) -- time until it returns to normal
for bodypart, color in pairs (SavedColorTable) do
character[bodypart].Color = color
end
for i,Child in pairs (character:GetChildren()) do
if Child:IsA("BasePart") then
Child.Material = 'Plastic'
end
end
task.wait(0)
for i,Child in pairs (character:GetChildren()) do
if Child:IsA("Accessory") then
local ChildA = Child:FindFirstChildWhichIsA("Part")
ChildA.Color = Color3.fromRGB(255, 255, 255)
ChildA.Material = 'Plastic'
end
end
end
local function onPlayerAdded(player)
player.CharacterAppearanceLoaded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)