I want to disable all particles from things the player is wearing.
This is the script I wrote and placed in StarterCharacterScript, but It didn’t work.
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
wait(15)
for i, fplayer in pairs(Player:GetDescendants()) do
if fplayer:IsA("ParticleEmitter") then
fplayer.Enabled = false
end
end
First I thought, It didn’t work, because the player didn’t existed yet, but since it waited 15 seconds, this can’t be the error…
I suggest using a Server Script for this
(Server Script in ServerScriptService)
game:GetService("Players").PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
Char:WaitForChild("Humanoid")
task.wait(1) --// So we know that the players character has fully loaded
for i,v in pairs(Char:GetDescendants()) do
if (v.ClassName == "ParticleEmitter") then
v.Enabled = false
end
end
end)
end)
first of all, the script you posted will disable the particles from your player only (so basically you’ll still be able to see other players particles)
second, don’t use wait(15), try something like player.CharacterAdded instead (to wait for the character to load)
and third, you’re using getdescendants on the player object itself, not the character, that’s why it can’t find anything…
final script would be something like this:
local player = game:GetService'Players'.LocalPlayer;
if not player.Character then player.CharacterAdded:Wait() end;
local character = player.Character;
for _, object in next, character:GetDescendants() do
if object:IsA'ParticleEmitter' then
object.Enabled = false;
end;
end;
Yeah, I know that it only disables the effects for me (no wonder its a local script), but I actually wanted to achieve exactly that, this is why I did it in a localscript not ServerScript.
I fixed it by myself, by just changing it to the character.
This is the final script in case anyone need it:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character
repeat
wait()
until game:IsLoaded()
for i, fplayer in pairs(Character:GetDescendants()) do
if fplayer:IsA("ParticleEmitter") then
fplayer.Enabled = false
end
end
I fixed it by myself this is the final script in case someone needs it:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character
repeat
wait()
until game:IsLoaded()
for i, fplayer in pairs(Character:GetDescendants()) do
if fplayer:IsA("ParticleEmitter") then
fplayer.Enabled = false
end
end