For my script, essentially when the player presses the G button, the remote event fires into this script in question, which basically clones the character’s body parts, sets them to a transparency in order to mimic an “afterimage” or a “ghost” of the character. The goal was to allow the character to move normally while these “ghost” clone parts mimic the last position of each character body part so it replicates an after-effect.
The issue is that the player gets stuck in the cloned parts and can’t move. I tried to use the PhysicsService collision groups method and I attempted to set the cloned parts and the character model’s parts into their own collision groups and then making them uncollidable. It didn’t seem to work, although when I printed if the groups are collidable, it says they aren’t so I’m not sure what’s going on.
Here is the sample code below:
local userInputService = game:GetService("UserInputService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local Clone = replicatedStorage:WaitForChild("Clone")
local debris = game:GetService("Debris")
local physicsService = game:GetService("PhysicsService")
local collisionName = "v1"
local collisionName2 = "v2"
physicsService:CreateCollisionGroup(collisionName)
physicsService:CreateCollisionGroup(collisionName2)
physicsService:CollisionGroupSetCollidable(collisionName, collisionName2, false)
local function setCollision(part)
physicsService:SetPartCollisionGroup(part, collisionName)
print(part.Name)
print(collisionName)
end
local function setCollision2(part)
physicsService:SetPartCollisionGroup(part, collisionName2)
print(part.Name)
print(collisionName)
end
Clone.onServerEvent:Connect(function(player)
local character = player.Character
for _,v in pairs(character:GetChildren()) do
if v.ClassName == "MeshPart" or v.ClassName == "Part" then
local v2 = v:Clone()
v2.Name = v.Name .."2"
setCollision(v)
setCollision2(v2)
v2.CanCollide = false
v2.CanTouch = false
v2.Anchored = true
v2.Transparency = 0.5
v2.Position = v.Position
v2.Parent = player.Character
debris:AddItem(v2, 3)
end
end
end)
Maybe I just went about it the wrong way, if someone could give some guidance that would be appreciated!