@moooichido

Как перевести в скрипте R15 на R6?

Я смог что-то написать, раньше когда я умирал он у меня переставал работать, я его смог исправить, а как переписать теперь на R6 не знаю

Это первый скрипт который взаимодействует с персонажем, как и второй, только второй отвечает за подсветку игрока:
local RunService = game:GetService("RunService")

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local root: BasePart = char:WaitForChild("HumanoidRootPart")
local cam = workspace.CurrentCamera

-- Clone character
char.Archivable = true
local fakeChar = char:Clone()
local fakeRoot: BasePart = fakeChar:WaitForChild("HumanoidRootPart")
fakeRoot.CanCollide = false
fakeChar.Name = "Fake" .. plr.Name
fakeChar.Parent = workspace

local scaleFactor = 0.999
local classesToRemove = {"Decal", "Texture", "SurfaceAppearance", "LocalScript", "Script", "Humanoid", "Clothing", "ShirtGraphic"}

for _, desc in fakeChar:GetDescendants() do
	if not desc:IsA("MeshPart") then continue end
	
	desc.CastShadow = false
	desc.Transparency = 0.9999999
	desc.Color = Color3.new(1, 1, 1)
	desc.Material = Enum.Material.Glass
	desc.TextureID = "rbxassetid://5307016674"
	desc.CollisionGroup = "CharacterHighlightMask"
	
	for _, child in desc:GetChildren() do
		if child:IsA("SurfaceAppearance") then child:Destroy() end
	end
end
fakeChar:ScaleTo(scaleFactor)

local fakeMotor6DTable: {Motor6D} = {}
for _, desc in ipairs(fakeChar:GetDescendants()) do
	if desc:IsA("Motor6D") then
		table.insert(fakeMotor6DTable, desc)
	end
end

local mainMotor6DTable: {Motor6D} = {}
for _, desc in ipairs(char:GetDescendants()) do
	if desc:IsA("Motor6D") then
		table.insert(mainMotor6DTable, desc)
	end
end

local humanoid = char:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
	fakeChar:Destroy()
end)

for _, desc in fakeChar:GetDescendants() do
	if desc:IsA("Highlight") then
		desc:Destroy()
	end
end

RunService.RenderStepped:Connect(function()
	fakeChar:ScaleTo(1)
	for i, fakeMotor6D: Motor6D in fakeMotor6DTable do
		local mainMotor6D = mainMotor6DTable[i]
		fakeMotor6D.C1 = mainMotor6D.C1 * mainMotor6D.Transform:Inverse()
	end
	fakeChar:ScaleTo(scaleFactor)
	
	local distanceToRoot = (root.CFrame.Position - cam.CFrame.Position).Magnitude
	local directionToRoot = (root.CFrame.Position - cam.CFrame.Position).Unit
	fakeRoot.CFrame = root.CFrame - directionToRoot * distanceToRoot * (1 - scaleFactor)
end)

for _, desc in fakeChar:GetDescendants() do
	if table.find(classesToRemove, desc.ClassName) then desc:Destroy() end
end


Второй скрипт, который отвечает за подсветку:
local RunService = game:GetService("RunService")

local cam = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

if script.Highlight then
	script.Highlight.Adornee = char
end

local fakeChar
repeat
	fakeChar = workspace:FindFirstChild("Fake" .. plr.Name)
	task.wait()
until fakeChar

if script.HighlightMask then
	script.HighlightMask.Adornee = fakeChar
end

char.Humanoid.Died:Connect(function()
	print("Character died. Removing highlights.")

	if script.Highlight then
		script.Highlight.Adornee = nil
		print("Highlight removed.")
	else
		print("Highlight does not exist.")
	end

	if script.HighlightMask then
		script.HighlightMask.Adornee = nil
		print("HighlightMask removed.")
	else
		print("HighlightMask does not exist.")
	end
end)
  • Вопрос задан
  • 40 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы