I'm making trail for GPS that parenting to torso, but there is a problem, it uses PlayerAdded. It doesn't creates trail if you die, how do i fix it?
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local name = player.Name
local a = Instance.new("Attachment")
local t = Instance.new("Trail")
a.Parent = game.Workspace:WaitForChild(name):WaitForChild("LowerTorso")
a.Name = "loc0"
t.Parent = game.Workspace:WaitForChild(name):WaitForChild("LowerTorso")
t.Name = "GPS"
t.MaxLength = 1
t.MinLength = 1
t.Lifetime = 0
t.Attachment0 = t.Parent:FindFirstChild("loc0")
end)
Script isn't local if you ask
local player = game.Players.LocalPlayer
local t = player.Character:WaitForChild("LowerTorso"):FindFirstChild("GPS")
local button = script.Parent
local function onButtonActivated()
t.Attachment1 = game.Workspace.Keypoints.Point1.loc1
end
button.Activated:Connect(onButtonActivated)

25 comments
doesn't work after that at all, even if you start the game, it just wont create any trail anymore
It's doesn't work with the script you gave me too. The Attachment(loc0) and Trail(GPS) get added to the character after respawn, the trail just doesn't show, it didn't with the script you gave me too.
what you expected, you inserted player.CharacterAdded:Connect into PlayerAdded, :Connect must be outside of the function as i know
Nope, it can be inside too. The script does work as the instances get added into the character, just the trail doesn't work for some reason. Are you sure your trail does work?
It didn't work because the lifetime was too short and it needed 2 attachments, the script only made one. I updated my answer, try the script from my answer now.
it doesnt need second attachment, it creates when you choice location
it doesnt need second attachment, it creates when you choice location
Well, the script works now and it didn't work without the second attachment.
the scriprt just creates line that gives you lead to the hotel or other location
OH, I thought you wanted to make a normal trail lmao. I am not sure why the previous script didn't work because I don't have the whole script.
i edited my post so you can see local script of the button
Updated my answer again. The script does work the way it is supposed to (at least if I got what you wanted it to do)
where parent of script must be? cause it still doesn't creates anything inside LowerTorso, i checked out it multiple times, even after resets it still doesn't creates any trail or attachment, parent is server script service
It doesn't matter where the script is. Is your game R6 or R15?
by the way, the parent of char gives nil, means it doesnt searches for workspace character
r15
Did you copy the scripts or did you make some changes? The scripts work for me no matter where they are, they work in r15 only, and the character isn't nil for me.
my game is r15 only, it doesnt work, i removed second local t, added print to check if character is nil "print (char.Parent)" to see if it looks for player from workspace, not from players folder
Wait what second local t?
local a* you did 2 local a's
Also char doesn't really have a parent if it's found by the event. Making the script print char parent will break the whole thing.
Right, the first local a is the wrong one, you need to keep the second, I will edit my answer, copy it again.
nah still, no effect, it just doesnt create the trail and attachment, or just doesn't parents it to lower torso, no errors, just no effect
You can send me the codes you have currently in discord. [CLASSIFIED]#9999 so I can have a look.
k, ill do this tommorow