Hey I have a weird error in my code.
I'm developing a game with a player particle effect, so I want to equip the player with its particle effect when he rejoins the game. (if he had one saved)
For example if I connect and I have the particle #6 saved, the line 71 should activate but nothing happens.
PS: sorry for my bad english i'm french haha
game.Players.PlayerAdded:connect(function(player)
wait(10)
print("Check if ".. player.Name .." as Particule saved")
local ld = player.leaderstats
print("Yeah Particle ID ".. ld.Particle.Value .." found. Try to auto-equipe this to player.")
if ld.Particle.Value == "1" then
local char = workspace:WaitForChild(player.Name)
local ID = ld.Particle.Value
if char.LowerTorso:FindFirstChild("Particle") then
char.LowerTorso["Particle"]:Destroy()
local particle = game.ReplicatedStorage.Shop.Particles[ID].Particle:Clone()
particle.Parent = char.LowerTorso
else
local particle = game.ReplicatedStorage.Shop.Particles[ID].Particle:Clone()
particle.Parent = char.LowerTorso
end
elseif ld.Particle.Value == "2" then
local char = workspace:WaitForChild(player.Name)
local ID = ld.Particle.Value
if char.LowerTorso:FindFirstChild("Particle") then
char.LowerTorso["Particle"]:Destroy()
local particle = game.ReplicatedStorage.Shop.Particles[ID].Particle:Clone()
particle.Parent = char.LowerTorso
else
local particle = game.ReplicatedStorage.Shop.Particles[ID].Particle:Clone()
particle.Parent = char.LowerTorso
end
elseif ld.Particle.Value == "3" then
local char = workspace:WaitForChild(player.Name)
local ID = ld.Particle.Value
if char.LowerTorso:FindFirstChild("Particle") then
char.LowerTorso["Particle"]:Destroy()
local particle = game.ReplicatedStorage.Shop.Particles[ID].Particle:Clone()
particle.Parent = char.LowerTorso
else
local particle = game.ReplicatedStorage.Shop.Particles[ID].Particle:Clone()
particle.Parent = char.LowerTorso
end
elseif ld.Particle.Value == "4" then
local char = workspace:WaitForChild(player.Name)
local ID = ld.Particle.Value
if char.LowerTorso:FindFirstChild("Particle") then
char.LowerTorso["Particle"]:Destroy()
local particle = game.ReplicatedStorage.Shop.Particles[ID].Particle:Clone()
particle.Parent = char.LowerTorso
else
local particle = game.ReplicatedStorage.Shop.Particles[ID].Particle:Clone()
particle.Parent = char.LowerTorso
end
elseif ld.Particle.Value == "5" then
local char = workspace:WaitForChild(player.Name)
local ID = ld.Particle.Value
if char.LowerTorso:FindFirstChild("Particle") then
char.LowerTorso["Particle"]:Destroy()
local particle = game.ReplicatedStorage.Shop.Particles[ID].Particle:Clone()
particle.Parent = char.LowerTorso
else
local particle = game.ReplicatedStorage.Shop.Particles[ID].Particle:Clone()
particle.Parent = char.LowerTorso
end
elseif ld.Particle.Value == "6" then
local char = workspace:WaitForChild(player.Name)
local ID = ld.Particle.Value
if char.LowerTorso:FindFirstChild("Particle") then
char.LowerTorso["Particle"]:Destroy()
local particle = game.ReplicatedStorage.Shop.Particles[ID].Particle:Clone()
particle.Parent = char.LowerTorso
else
local particle = game.ReplicatedStorage.Shop.Particles[ID].Particle:Clone()
particle.Parent = char.LowerTorso
end
end
end)
I think Roblox detects that the two values ??are equal but that it does not execute the code afterwards and I do not understand why.

2 comments
Try printing the value before line 71 and reading the output in the output pane, you may be surprised to see that it may not be equil to that you believe it is. Or, try storing Id.Particle.Value in a local variable and then using the variable to see if it's equil to 6, Roblox does not like you calling objects values directly in if statements.
if I print the value just before line 71 it is equal to 6. I will try with the local variable.