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

Help me fix this script?

I'm trying to make it so that a part appears under a players foot constantly.

This is the script I currently have.

while wait(0.1) do
	trail = Instance.new("Part", game.Workspace)
	local Players = game.Players:GetChildren()
	trail.Position = Players.Torso.CFrame * -4
end

1 answer

✓ Accepted answer

You cannot place a part beneath a table of Players. You must loop through all the players and place the part under their character from there. In this script, we will use a for loop.

You also cannot multiply an integer to a CFrame value, and a part's Position property is a Vector3 value, not a CFrame value.

while wait(0.1) do
    local trail = Instance.new("Part", game.Workspace)
    local Players = game.Players:GetChildren()
    for i,v in pairs(Players) do --Loops through all the players so trails appear underneath them individuall.
        repeat wait() until v.Character --Waits until the player's character spawns.
        trail.CFrame = v.Character.Torso.CFrame * CFrame.new(0, -4, 0) --You access the CFrame of the parts, not the Vector3. You must multiply the current CFrame value with a new CFrame value so they all match up.
    end
end

Here is more information on for loops. Here is more information on CFrame.

If I helped you out, be sure to accept my answer!

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