Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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
0
PlayerAdded and CharacterAdded should both be outside the function, not inside of it. DeceptiveCaster 3761 — 4y

2 answers

Log in to vote
0
Answered by
sheepposu 561 Moderation Voter
4 years ago

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

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?? BlackArcher2016 7 — 4y
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 sheepposu 561 — 4y
Ad
Log in to vote
0
Answered by
SmartNode 383 Moderation Voter
4 years ago

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.

Answer this question