im recreating an old game was wondering how to set castshadow to false for all the parts in every player in the game
You can use a for loop to loop through every character in workspace, and another for loop to loop through every part inside of the character(s). Once done, we can set castshadow to false.
for i,v in pairs(workspace:GetChildren()) do
if game.Players:GetPlayerFromCharacter(v) then
for _, characterPart in pairs(v:GetChildren()) do
if characterPart:IsA("BasePart") then
characterPart.CastShadow = false
end
end
end
end
thanks for the response, but using this script doesnt change any of the shadows.
i did add a print statement after
if game.Players:GetPlayerFromCharacter(v) then
but it didnt end up printing anything
No problem, that’s pretty strange, it works fine for me.
maybe im putting the script in the wrong place? where should i be putting the script
That depends, what is the script for? Can I see the entire script so I can help?
im just using the same script you sent and its a localscript in StarterPlayerScripts, am i making a dumb mistake? sorry if i am
for i,v in pairs(workspace:GetChildren()) do
if game.Players:GetPlayerFromCharacter(v) then
print("test")
for _, characterPart in pairs(v:GetChildren()) do
if characterPart:IsA("BasePart") then
characterPart.CastShadow = false
end
end
end
end
serverscriptservice >
i assume you want a server script anyway, i just realized itd work both tho
local mtb={['plrs']=game:GetService('Players')}
mtb.bpadded=function(x)
if x:IsA('BasePart') then x.CastShadow=false end
end
mtb.chadded=function(x)
x.DescendantAdded:Connect(mtb.bpadded)
for i,v in next,x:GetDescendants() do mtb.bpadded(v) end
end
mtb.plradded=function(x)
if x.Character then mtb.chadded(x.Character) end
x.CharacterAdded:Connect(mtb.chadded)
end
mtb.plrs.PlayerAdded:Connect(mtb.plradded)
for i,v in next,mtb.plrs:GetPlayers() do mtb.plradded(v) end mtb.plrs=nil
edit: forgot something
No, dw there aren’t such things as dumb mistakes, it’s what helps you learn.
Are you trying to make it so only the client/player can see that everyone’s shadows are off, or are the shadows going to be off for everyone?
If it’s only visible to the player, then you would make it a localscript, and I can help you from there. If it’s visible to everyone, make a Script, and place it into ServerScriptService.
thanks for not being condescending @username7768 's script seems to have done the trick, but yes my goal was to have it turn shadows off for everyone.
thank you for the help though
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.