Hi guys I'm trying to make it so the trail will only show when the player is pressing left shift. This is what I got so far, but it's not working. I'm pressing left shift but the trail is not showing. Any help is appreciated. Thanks!
UserInputService = game:GetService("UserInputService") if UserInputService:IsKeyDown(Enum.KeyCode.LeftShift) then game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) local trail = game.ServerStorage.Trail:Clone() trail.Parent = char.Head local attachment0 = Instance.new("Attachment", char.Head) attachment0.Name = "TrailAttachement0" local attachment1 = Instance.new("Attachment", char.HumanoidRootPart) attachment1.Name = "TrailAttachement1" trail.Attachment0 = attachment0 trail.Attachment1 = attachment1 end) end) end
Make a LocalScript, in Player Scripts. Check if the player is pressing Left Shift and if so, then reveal the path. From the looks of it, this is a server script. If you want to change the path Server Wide then use an event function. The way you have it now, it will check as once as soon as the server starts and create a new trail and stuff every time the character joins (every time they spawn).
UserInputService only works for the client (I believe)
Thus, you should be using a localscript for this. Place the trail somewhere the player has access to (like ReplicatedFirst)
Then create a localscript that gets the user input, clone the trail, weld it to whatever you need it to weld, then delete/disable it once the player has let go of the shift key.