I have a trail gamepass that has been working for months, but I just noticed it is not functioning correctly anymore. Whenever a player resets it is no longer reinserting the “trail” into the players head.
Inside of Server Script Service
local marketplaceservice = game:GetService("MarketplaceService")
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
if marketplaceservice:UserOwnsGamePassAsync(plr.UserId, 10062763) then
local char = plr.Character or plr.CharacterAdded:wait()
local attach1 = Instance.new("Attachment",char:WaitForChild("Head"))
local attach2 = Instance.new("Attachment",char.HumanoidRootPart)
local trail = game.ServerStorage.Trail:Clone()
trail.Parent = char.Head
trail.Attachment0 = attach1
trail.Attachment1 = attach2
end
end)
end)
In the script alone there are no errors. However I do have a button that allows you to toggle the trail on or off. It works fine up until the player resets. After I reset and try to use the toggle the error I get is
“Trail is not a valid member of MeshPart “Workspace.KvngAf.Head” -”
Hm strange because it works in my studio, I reset and it puts the trail in my head like it’s supposed to. It may be an issue with your toggle button or the gamepass itself, try replacing the current ID with an ID from another gamepass that you own from another game or something. Let me know if there are any future issues
I know that, but read the error.
"Trail is not a valid member of MeshPart “Workspace.KvngAf.Head”
'There is nothing in the above script trying to attach something to the trail itself.
The error is from a script for the button to toggle the trail, since that script can’t find the trail then it’s an issue outside of that script. Like @kojocrash said it might be another script interfering with it.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local trail = ReplicatedStorage:WaitForChild("trail")
local player = game:GetService("Players").LocalPlayer
local plrName = player.Name
local char = game.Workspace:WaitForChild(plrName)
local charHead = char:WaitForChild("Head")
script.Parent.MouseButton1Click:Connect(function()
trail:FireServer()
charHead.Trail.Enabled = false
end)
ServerScriptService (Server Script)
local ReplicatedStorage = game.ReplicatedStorage
local remoteEvent = ReplicatedStorage:WaitForChild("trail")
remoteEvent.OnServerEvent:Connect(function(player)
local charHead = workspace:WaitForChild(player.Name).Head
charHead.Trail.Enabled = false
end)
Im having no issues with the toggle, I have other game passes that work fine with the toggle. Even when removing the toggle the trail does not reinsert on spawn.
I understand that but I don’t think you realize that scripts run as soon as their instance is created unless it’s disabled. So by adding that wait you’re making sure that the trail does exist before attempting to toggle it. It will just wait until the trail is created.