I’m not sure what I did wrong here, when a Player joins the game I simply want to add a Particle to their Torso. I tried looking up examples of how it’s done but there was none.
The script isn’t erroring for me which also doesn’t help me.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local Humanoid = character:WaitForChild("Humanoid")
local HeartEffect = game.ServerStorage.Effects:WaitForChild("Hearts")
local Torso = player.Character:FindFirstChild("UpperTorso")
HeartEffect = Torso
end)
end)
Ah very close, but you’re not quite doing what you need to do for HeartEffect. You’ll want to clone it and set its parent of the cloned effect, which you apparently are not doing. HeartEffect = Torso sets the HeartEffect variable to the UpperTorso you got earlier.
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local Humanoid = character:WaitForChild("Humanoid")
local HeartEffect = game.ServerStorage.Effects:WaitForChild("Hearts"):Clone()
local Torso = character:FindFirstChild("UpperTorso")
HeartEffect.Parent = Torso
end)
end)
I tried what @DataSigh mentioned but issue with it. It duplicates the whole File and doesn’t place it in the Torso so the ParticleEmitter just spawns in the middle of the baseplate.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local Humanoid = character:WaitForChild("Humanoid")
local HeartEffect = game.ServerStorage.Effects:WaitForChild("Hearts")
local Torso = player.Character:FindFirstChild("UpperTorso")
HeartEffect = Torso
end)
end)
for _, player in Players:GetPlayers() do
player.CharacterAdded:Connect(function(character)
local Humanoid = character:WaitForChild("Humanoid")
local HeartEffect = game.ServerStorage.Effects:WaitForChild("Hearts")
local Torso = player.Character:FindFirstChild("UpperTorso")
HeartEffect = Torso
end)
end
Still doesn’t work and there’s no errors in the output, what actually worked was adding the ParticleEmitter in StarterCharacterScripts but it doesn’t parent it to the Torso just the Character model for some reason.
I think it would be much better if the Effects file would be in the ServerStorage though.