What do you want to achieve?
I want the Face Decal to get Transparency 1 as the BasePart does.
What solutions have you tried so far?
Couldn’t find anything related to this.
Code:
for i, d in pairs(char:GetDescendants()) do
if d:IsA("BasePart") or d:IsA('Decal') then
spawn(function()
TS:Create(d, fadeTI,{Color = Color3.fromRGB(242, 179, 84), Transparency = 1}):Play()
local particles = script.Aura:Clone() and script.Fire:Clone() and script.Orbs:Clone()
particles.Rate = 10
TS:Create(particles, particlesTI, {Rate = 100}):Play()
particles.Parent = d
task.wait(2.5)
TS:Create(particles, particlesTI, {Rate = 0}):Play()
end)
end
end
Your main problem is that a decal doesn’t have a “Color” attribute, but instead only has a Color3 attribute. You should be getting an error for this too, so make sure you’re using the console to debug. To fix this, turn the if statement into an elseif statement to make different tweens for each corresponding class.
Not necessarily wrong, but using Pairs is now unnecessary due to an update back in May that is now live, though not many people have heard about this yet. Doing for i, d in char:GetDescendants() do should be the new norm. Release Notes 526. (Don’t know how I’ve seen literally nobody talk about this???).
For formatting, stick to one type of quotation instead of using both double quotes and single quotes for BasePart and Decal.
Use task.spawn() instead of spawn (read more about the task library here or here to learn more about that).
You’re assigning the variables to script.Aura:Clone() and script.Fire:Clone() and script.Orbs:Clone(). This is not how assigning variables with operators work. Here is a good post about how using operators when assigning variables work if you’re curious. Your solution could be to make all of the clones and put them in an array, and loop over the array whenever you edit them.
Would you help me to modify this code? I’m still learning and i got a bit confused about all this that you were saying… Would appreciate if you could help me formatting this x-x
for _, d in char:GetDescendants() do
if d:IsA("BasePart") or d:IsA("Decal") then
task.spawn(function()
local colorProperty = if d:IsA("Decal") then "Color3" else "Color"
TS:Create(d, fadeTI,{[colorProperty] = Color3.fromRGB(242, 179, 84), Transparency = 1}):Play()
local particles = {script.Aura:Clone(), script.Fire:Clone(), script.Orbs:Clone()}
for _, particle in particles do
particle.Rate = 10
TS:Create(particle, particlesTI, {Rate = 100}):Play()
particle.Parent = d
task.wait(2.5)
TS:Create(particles, particlesTI, {Rate = 0}):Play()
end
end)
end
end
Is telling me that “child” is an unknown global… This is the complete script i have with the changes you posted…
-- Services --
local RS = game:GetService('ReplicatedStorage')
local TS = game:GetService("TweenService")
-- Remotes --
local DeathRemote = RS.Remotes:WaitForChild('DiedRE')
-- Variables --
local fadeTI = TweenInfo.new(2, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
local particlesTI = TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
humanoid.BreakJointsOnDeath = false
end)
end)
DeathRemote.OnServerEvent:Connect(function(plr)
if not plr.Character or not plr.Character:FindFirstChild("Humanoid") then return end
local char = plr.Character
local humanoid = char.Humanoid
char.HumanoidRootPart.Anchored = true
--humanoid:LoadAnimation(script.DeathAnimation):Play()
for _, d in char:GetDescendants() do
if d:IsA("BasePart") or d:IsA("Decal") then
task.spawn(function()
local colorProperty = if child:IsA("Decal") then "Color3" else "Color"
TS:Create(d, fadeTI,{[colorProperty] = Color3.fromRGB(242, 179, 84), Transparency = 1}):Play()
local particles = {script.Aura:Clone(), script.Fire:Clone(), script.Orbs:Clone()}
for _, particle in particles do
particle.Rate = 10
TS:Create(particle, particlesTI, {Rate = 100}):Play()
particle.Parent = d
task.wait(2.5)
TS:Create(particles, particlesTI, {Rate = 0}):Play()
end
end)
end
end
end)
I accidentally put “child” instead of “d”. This is what the error code said, and it should have pointed to this line.
Here’s the complete script with that small fix:
-- Services --
local RS = game:GetService('ReplicatedStorage')
local TS = game:GetService("TweenService")
-- Remotes --
local DeathRemote = RS.Remotes:WaitForChild('DiedRE')
-- Variables --
local fadeTI = TweenInfo.new(2, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
local particlesTI = TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
humanoid.BreakJointsOnDeath = false
end)
end)
DeathRemote.OnServerEvent:Connect(function(plr)
if not plr.Character or not plr.Character:FindFirstChild("Humanoid") then return end
local char = plr.Character
local humanoid = char.Humanoid
char.HumanoidRootPart.Anchored = true
--humanoid:LoadAnimation(script.DeathAnimation):Play()
for _, d in char:GetDescendants() do
if d:IsA("BasePart") or d:IsA("Decal") then
task.spawn(function()
local colorProperty = if d:IsA("Decal") then "Color3" else "Color"
TS:Create(d, fadeTI,{[colorProperty] = Color3.fromRGB(242, 179, 84), Transparency = 1}):Play()
local particles = {script.Aura:Clone(), script.Fire:Clone(), script.Orbs:Clone()}
for _, particle in particles do
particle.Rate = 10
TS:Create(particle, particlesTI, {Rate = 100}):Play()
particle.Parent = d
task.wait(2.5)
TS:Create(particles, particlesTI, {Rate = 0}):Play()
end
end)
end
end
end)
I accidentally kept the variable as particles instead of particle since I switched around what the variables meant. This should fix it: TS:Create(particle, particlesTI, {Rate = 0}):Play().
Also one last question before the post closes… How could i make that the 2 particles play at the same time and not separate? Because right now Aura particles plays first, stops and Fire particle starts, stops and orbs particle starts…
What you need to do is move the task.spawn inside the loop. What can you even do after that is change that task.spawn function to a task.delay function so that you no longer need the task.wait.
for _, d in char:GetDescendants() do
if d:IsA("BasePart") or d:IsA("Decal") then
local colorProperty = if d:IsA("Decal") then "Color3" else "Color"
TS:Create(d, fadeTI,{[colorProperty] = Color3.fromRGB(242, 179, 84), Transparency = 1}):Play()
local particles = {script.Aura:Clone(), script.Fire:Clone(), script.Orbs:Clone()}
for _, particle in particles do
particle.Rate = 10
TS:Create(particle, particlesTI, {Rate = 100}):Play()
particle.Parent = d
task.delay(2.5,function()
TS:Create(particles, particlesTI, {Rate = 0}):Play()
end
end
end)
end