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

What Service or type of script is used to make a "part" appear behind your character when he walks?

Im thinking about making a game that makes it to where when you walk a part appears behind your character such as in murder mystery

2 answers

I would recommend that you have a LocalScript in every player that makes it so that every 5 or so seconds, a small part is made where their feet are, and then 25 seconds later, the part is destroyed.

Example:

wait();
script:destroy();--// Anti Death Removal

local Player=game:service'Players'.localPlayer;
local TrailSize=2;--// The trail size. Can be changed.

while(wait(5))do--// Do this every 5 seconds
	local Character=Player.Character;

	if(
		Character--// If they have a character
		and Character.Parent=workspace--// If the character is in the workspace ( prevents errors from falling off the base )
		and Character:findFirstChild'Right Leg'--// If they have a right leg
		and Character:findFirstChild'Left Leg'--// If they have a left leg
		and Character:findFirstChild'Humanoid'--// If they are a real character
		and Character.Humanoid.Health>0--// If they are alive
		and Character:findFirstChild'Torso';--// If they have a torso
		and Vector3.new(
			Character.Torso.Velocity.X,
			0,
			Character.Torso.Velocity.Z
		).magnitude>=2--// If they are walking
	)then
	
		local Trail=Instance.new('Part',workspace);--// Create the trail part
		Trail.Name='Trail: '..Player.Name;
		Trail.formFactor=3;
		Trail.CanCollide=false;
		Trail.Anchored=true;
		Trail.BrickColor=ChatColor.Get(Player.Name);--// *****
		Trail.TopSurface,Trail.BottomSurface=0,0;
		Trail.Size=Vector3.new(TrailSize,TrailSize/2,TrailSize);--// You can change this to represent the trail size.
		Trail.CFrame=
			CFrame.new(
				Vector3.new().lerp(
					Character['Right Leg'].CFrame.p,
					Character['Left Leg'].CFrame.p,
					.5
				),
				Character.Torso.CFrame.p--// Where the player's character is facing.
			)
			* CFrame.new(
				0,
				-Character['Right Leg'].CFrame.Y/2,--// In between the player's feet.
				-2 --// A little bit back.
			);

		game:service'Debris':addItem(Trail,25);--// Removes the trail part after 25 seconds

	end;
end;

***** Interesting ChatColor class found on NoliCAIKS' code snippet container. It gets the Player's chat color, which is determined by their name.

2 comments

0

When i play it in studio mode and walk around the baseplate nothing shows up. Do i have to be in Play Mode?

0

Is there an error? If so, it's because you did not put in the ChatColor module that I posted on my answer.

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