Hello as I said in the title I’m not an experienced scripter, I am a beginner and so what I did was find any free source script that interested me on the internet and then add it to my own game.
I found a mirror script that works properly both in R6 and R15 where it makes a clone of the player on the other side of the mirror and copies every single movement, as for now I made it so that the mirrored clone only appears/gets created when the other player is touching a part that I made invisible inside a room and it disappears/gets deleted after he stopped touching it.
The issues that I am encountering are 2, one in R6 where one of the accessories freezes in the air, and one in R15 where whenever I get close to a player in the mirror and then go far from them, their reflection disappears but on their screen, they still can see their reflection. Anyway I don’t think the script has any collision logic with the player so I don’t think that’s the issue, I asked someone else and they said it might be a rendering logic from Roblox’s side but I’m not sure.
R6 Accessory Issue Footage:
https://gyazo.com/01a03060cc982b94871d3b29532d352d
R6 - R15 Rendering Issue:
I believe this is where the issue relies, in these 4 functions:
function upDate(p, q)
local info
for _, v in pairs(parts) do
if v["Part"] == p then
info = v
end
end
if info == nil then
return false
end
local x, y, z, xx, yx, zx,
xy, yy, zy,
xz, yz, zz = mirror.Mirror_Part.CFrame:toObjectSpace(q.CFrame):components()
local xAxis = Vector3.new(xx, xy, xz)
local yAxis = Vector3.new(yx, yy, yz)
local zAxis = Vector3.new(zx, zy, zz)
xAxis = reflectVec(xAxis, info["xN"])
yAxis = reflectVec(yAxis, info["xN"])
zAxis = reflectVec(zAxis, info["xN"])
xAxis = -xAxis
local axis = ""
if info["xN"].X > 0 or info["xN"].X < 0 then
axis = "X"
end
if info["xN"].Y > 0 or info["xN"].Y < 0 then
axis = "Y"
end
if info["xN"].Z > 0 or info["xN"].Z < 0 then
axis = "Z"
end
if axis == "" then
return false
end
if axis == "X" then
p.CFrame = mirror.Mirror_Part.CFrame:toWorldSpace(CFrame.new(-x, y, z, xAxis.X, yAxis.X, zAxis.X, xAxis.Y, yAxis.Y, zAxis.Y, xAxis.Z, yAxis.Z, zAxis.Z))
elseif axis == "Y" then
p.CFrame = mirror.Mirror_Part.CFrame:toWorldSpace(CFrame.new(x, -y, z, xAxis.X, yAxis.X, zAxis.X, xAxis.Y, yAxis.Y, zAxis.Y, xAxis.Z, yAxis.Z, zAxis.Z))
elseif axis == "Z" then
p.CFrame = mirror.Mirror_Part.CFrame:toWorldSpace(CFrame.new(x, y, -z, xAxis.X, yAxis.X, zAxis.X, xAxis.Y, yAxis.Y, zAxis.Y, xAxis.Z, yAxis.Z, zAxis.Z))
end
end
-- Define the upDate_Char function
function upDate_Char(p, q)
if p == nil or q == nil then
return false
end
local tbl = {}
local num = {}
local sel = ""
for _, k in pairs(p:GetDescendants()) do
if k:IsA("BasePart") then
if num[k.Name] ~= nil and num[k.Name] > 0 then
tbl[k.Name .. num[sel]] = k
else
tbl[k.Name] = k
end
sel = k.Name
if num[sel] == nil then
num[sel] = 1
else
num[sel] = num[sel] + 1
end
end
end
num = {}
sel = ""
for _, k in pairs(q:GetDescendants()) do
if k:IsA("BasePart") then
local key = k.Name
if num[sel] then
key = key .. num[sel]
end
local partToUpdate = tbl[key] or tbl[k.Name]
if partToUpdate then
upDate(partToUpdate, k)
if k.Name ~= "Handle" and (string.find(k.Name, "Hand") or string.find(k.Name, "Arm")) then
local rotx, roty, rotz = partToUpdate.CFrame:toEulerAnglesXYZ()
local oldCF = partToUpdate.CFrame -- Define oldCF here
--partToUpdate.CFrame = oldCF
local oppositePartName = string.find(k.Name, "Right") and string.gsub(k.Name, "Right", "Left") or string.gsub(k.Name, "Left", "Right")
local oppositePart = q:FindFirstChild(oppositePartName)
if oppositePart then
upDate(partToUpdate, oppositePart)
end
end
end
sel = k.Name
if num[sel] == nil then
num[sel] = 1
else
num[sel] = num[sel] + 1
end
end
end
return true
end
local function addChar(p)
if not mirror.Players:FindFirstChild(p.Name) and p.Character then
local l = p.Character:Clone()
if l:IsA("Model") then
for _, k in pairs(l:GetDescendants()) do
if k:IsA("BasePart") then
mirror_Part(k)
k.CanCollide = false
k.Anchored = true
end
end
end
l.Parent = mirror.Players
local rep
rep = game:GetService("RunService").Heartbeat:Connect(function()
local bool = upDate_Char(l, p.Character)
if not bool then
rep:Disconnect()
end
end)
end
end
local function delChar(p)
local character = mirror.Players:FindFirstChild(p.Name)
if character then
character:Destroy()
end
end