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

Help me fix this script?

Asked by 8 years ago

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

Log in to vote
1
Answered by
Discern 1007 Moderation Voter
8 years ago

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!

Ad

Answer this question