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

What would be the best approach for an "Afterimage"?

Asked by 8 years ago

I've been chipping away at an idea of mine for like maybe a week now, and it's in it's final, painful stages. Basically if you've ever played one of the Mario Galaxy games, you may be familiar with how the Starman powerup creates little rainbow afterimages that disappear right afterwards.

speedBoost.Touched:connect(function(tbl) --Phantom Rainbow Trail
    if tbl and tbl.Parent and tbl.Parent:FindFirstChild("Humanoid")and trailOn then
        trailOn = false
        local smooth = Enum.SurfaceType.SmoothNoOutlines
        local plrParts = {tbl.Parent["Right Arm"], tbl.Parent["Left Arm"], tbl.Parent["Right Leg"], tbl.Parent["Left Leg"], tbl.Parent.Torso, tbl.Parent.Head} --Puts the Player's Parts into a table for easy (I hope) manipulation
        while true do
            wait(1/60)
            for i,v in ipairs(plrParts)do
                print(i,v:GetFullName()) -- Early Debug
                local phantom = v:Clone()
                phantom.Name = (tostring(tbl.Parent)..tostring(v.Name)) 
                phantom:BreakJoints()
                phantom.Anchored = true
                phantom.CanCollide = false
                phantom.Parent = workspace
                phantom.TopSurface = smooth
                phantom.BottomSurface = smooth
                phantom.FrontSurface = smooth
                phantom.LeftSurface = smooth
                phantom.RightSurface = smooth
                phantom.BackSurface = smooth
                phantom.CFrame = CFrame.new(v.Position - 5 * v.CFrame.lookVector) -- My main issue at the moment
                for i,child in pairs(phantom:GetChildren()) do
                    if child:IsA("Weld") or child:IsA("Motor6D")then -- Clears away mainly the HeadWelds that :BreakJoints() ignores
                    child:Destroy()
                    end
                end
            end
        end
    end
end)

On the touch of the PowerUp, earlier in the script Music and the effect are added. In this section I started off by putting all of the player's parts into a table then using an iterative loop to apply the properties across all of the cloned parts. My main issue is with this block which is meant to position the parts a bit behind the player

phantom.CFrame = CFrame.new(v.Position - 5 * v.CFrame.lookVector) 

But this causes this to happen https://gyazo.com/4ba02031f38a7f6a4dfbe1f479321df8

If someone could help me sort that out and also let me know if cloning the parts saved to a table is actually a way to do this, because a lovely side effect of this is this: https://gyazo.com/41d9d6cbfadc2c526688597639d7c4b3 If I recall, Roblox can't handle removing all of these parts due to their name.

I've been peeking at the source code for the Gold Eagle Sword http://www.roblox.com/Gold-Eagle-Sword-item?id=264990158 to try to get an idea after the fact of another way my afterimage could be done, but it has to do with creating model instances and correct CFraming, both of which I haven't mastered yet.

Any and all help will be appreciated, Thanks! ~MBacon15

0
Make the parts of the afterimages unable to CanCollide, and then group them in Models into a table. And then either spawn a function to make the parts disappear, or just stick the Model in Debris. User#6546 35 — 8y
0
Any tips on where to start. My main issue is with the plrParts table being a part of the character. So cloning the parts brings all of the children and CFraming them seems to CFrame the character as well. MBacon15 97 — 8y

Answer this question