I want to put two attachments in the local player's HumanoidRootPart and a Trail in the local player (I'm making a shift-to-sprint function that enables a trail behind the player when the sprint is active). How would I do this? I don't want to use a custom playermodel, so would I use a LocalScript in the starterpack?
EDIT: Here's what I've got so far.
game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) local attach1 = Instance.new("Attachment") attach1.Position = Vector3.new(0,2.25,0) attach1.Parent = Character.HumanoidRootPart local attach2 = Instance.new("Attachment") attach2.Position = Vector3.new(0,-2.25,0) attach2.Parent = Character.HumanoidRootPart local trail = Instance.new("Trail") trail.Attachment0 = attach1 trail.Attachment1 = attach2 trail.Parent = Character end) end)
Sorry for wasting everyone's time. I figured it out.
Remember, all scripts in LocalScript not give a Object to all players! and not work game.Players.PlayerAdded in LocalScript
you script are good. You just need to put this script in Server Script.
game.Players.PlayerAdded
does not work in LocalScript. You need to use this in a Server Script in Workspace or ServerScriptService.
You can see more here: Roblox Wiki - PlayerAdded
Summary: Put your script in Server Script. and put the Server Script in Workspace or ServerScriptService
Hope it helped! :)