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

In the output box it says Trail is missing from the ServerStorage yet it is there.Please help?

Asked by 6 years ago

https://gyazo.com/619c1596146f257ccdf70ed713826bd2 This is the screenshot it says something is missing from the ServerStorage yet it is there. Please Help.

2 answers

Log in to vote
0
Answered by 6 years ago

Scripts that load immediately often have errors like this because objects typically aren't instantly loaded in. The best way to fix this would be to use :WaitForChild to make sure that the script can see the object before you try to reference it. This should fix your problem:

local Trail = game.ServerStorage:WaitForChild("Trail")

game.Players.PlayerAdded:Connect(function(Player)
     Player.CharacterAdded:Connect(function(Character)
          local PlayerTrail = Trail:Clone()
          PlayerTrail.Parent = Character.Torso
          PlayerTrail.Attachment0 = Character.Head.FaceFrontAttachment
          PlayerTrail.Attachment1 = Character.Torso.WaistBackAttachment
     end)
end)
Ad
Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

That's not how you get objects.

You should either do

local Trail = game.ServerStorage.Trail

or

local Trail = game.ServerStorage:WaitForChild("Trail")

But you don't use () parantheses to index an object. At most [] ones to evaluate the string you put inside them.

Answer this question