Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Does anyone know how to make a particle trail and give it to the player when he touches a block?

I have tried multiple ways to make a particle trail system for the player when they touch the block, but unfortunately I have had no luck with making it. Can someone please help me make a particle trail system. It would be very helpful! (I was never really good at scripting in "Lua Script" anyway. I am still learning Info: These are ways that I tried to make a particle trail system, bu t they didn't work)

game.Players.PlayerAdded:connect(function(plr)
    local plrName = plr.Name
    plr.CharacterAdded:connect(function(char)
        local plrTorso = char:WaitForChild("Torso")
        local sTrail = Instance.new("ParticleEmitter")
        sTrail.Name = "TrailTest"
        sTrail.Parent = plrTorso
    end)
end)

3 comments

0

Please know that we're not supposed to just make code for you. We're supposed to help you with code you've already made...

0

This didn't work? I don't see anything wrong with this script.

0

What's the purpose of variable "plrName?" It's not used anywhere in your code. And why're you using the PlayerAdded & CharacterAdded events when you're trying to have the particles emit when a player touches a part?

2 answers

✓ Accepted answer

Use a Touched Event...

Part = script.Parent

Part.Touched:connect(function(hit) -- Use the touched event on a brick( hit refers to the part or brick that is hit by 'Part')
	if hit.Parent:FindFirstChild('Humanoid') then -- If there is a humanoid it is more likely to be a player
		local Player = game.Players:GetPlayerFromCharacter(hit.Parent) 
		if Player ~= nil then -- checks to see if the model or Parent is actually a player
			local Particles = Instance.new('ParticleEmitter') -- Creates the PartleEmitter inside of the Torso
			Particles.Parent = hit.Parent.Torso
		end
	end
end)

Remember to try and do your best to make a script before asking us to make one for you, because most of the time we will not make one from scratch.

Keep that in mind...

local Particles = script.Parent.ParticleEmitter --Defines the particles

script.Parent.Touched:connect(function(hit) --TouchedEvent
	wait() --waits
	local ParticlesClone = Particles:Clone() --Clones the particles
	ParticlesClone.Parent = hit --puts the particles inside of the object that hit the part
	
end) --closes the function

--]] 'hit' basically represents that part that is 'hitting' the brick. You can also change the 'hit(s)' other properties: 

		-- 	hit.Material = "Neon"		
		--	hit.BrickColor = BrickColor.Random()

--Copy this code into a script located inside a part or brick.

This discussion is preserved as it was. New answers, comments, and votes are closed.