I have a script that makes a PointLight that has shadows enabled spawn inside the players HumanoidRootPart, but the shadows show the players accessories, arms, legs, etc. I need the player accessories, etc, to have CastShadow disabled when they spawn.
local Players = game:GetService("Players")
local function onCharAdded(char)
for i, v in ipairs(char:GetDescendants()) do
if v:IsA("BasePart") then
v.CastShadow = false
end
end
end
local function onPlrAdded(plr)
charAddConns[plr] = plr.CharacterAdded:Connect(onCharAdded)
end
local function onPlrRemoving(plr)
charAddConn[plr]:Disconnect()
charAddConns[plr] = nil
end
Players.PlayerAdded:Connect(onPlrAdded)
Players.PlayerRemoving:Connect(onPlrRemoving)
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
for _, v in pairs(Character:GetChildren()) do
if v:IsA("BasePart") then
v.CastShadow = false
end
end
end
end
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
for _, v in pairs(Character:GetChildren()) do
if v:IsA("MeshPart") then
v.CastShadow = false
end
end
end
end
CharacterAppearanceLoaded waits for all objects to load into the character iirc. But yeh, you simply have to for loop through the character’s children.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Connect(function(character)
for i , v in pairs(character:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("UnionOperation") or v:IsA("MeshPart") then
v.CastShadow = false
end
end
end)
end)
Understand this that Local Script is only on the clients side but a Server Script is in the whole server for every player. So if you do this in a local script it will only be on the client that this works i.e only for you your shadow is invisible but other players can see it but if you put this in a server script it will be server wide so then no body can see any other persons shadow.