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

How to make it so the trail shows when the player is pressing left shift?

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

1 comment

0

PlayerAdded and CharacterAdded should both be outside the function, not inside of it.

2 answers

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).

2 comments

0

how would I change the path to Server Wide with which event? Or would it just be better to have it in the player scripts??

0

Server wide means all players can see the change. If you change it with the LocalScript only the local player will see the changes. Which event? Make one in Replicated storage, fire it from the local script, and catch it with a server script in ServerScriptService

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.

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