After Image not working
I’m making an after-image script that involves cloning the players model on a key press, and anchoring it at their current position.
-- | Services
local TweenService = game:GetService("TweenService")
local PhysicsService = game:GetService("PhysicsService")
local debris = game:GetService("Debris")
local RemoteEvent = game.ReplicatedStorage.ClientToServer
RemoteEvent.OnServerEvent:Connect(function(Player)
print("test")
local Shunpo = Instance.new("Sound")
Shunpo.SoundId = "rbxassetid://1721022491"
Shunpo.Parent = workspace
Shunpo:Play()
-- | Variables
local character = Player.Character
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character.HumanoidRootPart
-- | Misc
character.Archivable = true
-- | Tables
local tweenGoals = {
FlashInfoIn = TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0),
FlashInfoOut = TweenInfo.new(0.05, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, false, 0),
-- || Clone Fade Out
tweenFlashtepIn = {
Transparency = 1,
Color = Color3.new(0, 0, 0)
};
-- || Humanoid Fade In
tweenFlashtepOut = {
Transparency = 0,
};
}
local characterModel = character:Clone()
-- | Player Transparency
for i, v in pairs(character:GetDescendants()) do
if v:IsA("Part") then
v.Transparency = 1
elseif v:IsA("Accessory") then
v.Handle.Transparency = 1
elseif v:IsA("Decal") then
v.Transparency = 1
end
end
-- | Afterimage create
characterModel.Archivable = true
for i, clone in pairs(character:GetDescendants()) do
if clone:IsA("Part") or clone:IsA("MeshPart") then
print("Test2")
clone.Archivable = true
clone.CanCollide = false
clone.Anchored = true
print(clone)
end
characterModel.Parent = workspace
characterModel:FindFirstChild("Humanoid").DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
task.wait(0.5)
-- | Afterimage Transparency
for i, v in pairs(characterModel:GetDescendants()) do
if v:IsA("Part") then
TweenService:Create(v, tweenGoals.FlashInfoIn, tweenGoals.tweenFlashtepIn):Play()
elseif v:IsA("Accessory") then
TweenService:Create(v.Handle, tweenGoals.FlashInfoIn, tweenGoals.tweenFlashtepIn):Play()
end
end
characterModel.Head.face:Destroy()
task.wait(0.5)
for i, v in pairs(character:GetDescendants()) do
if v:IsA("Part") then
TweenService:Create(v, tweenGoals.FlashInfoOut, tweenGoals.tweenFlashtepOut):Play()
elseif v:IsA("Accessory") then
TweenService:Create(v.Handle, tweenGoals.FlashInfoOut, tweenGoals.tweenFlashtepOut):Play()
elseif v:IsA("Decal") then
v.Transparency = 0
end
end
characterModel:Destroy()
end
end)
The for loop under Afterimage create is what is supposed to handle the positioning, but it only prints (and seems to anchor) the clones head, and not the other limbs/parts/meshes. It’s just trying to solve it, since I’m completely lost on why that’s happening
