I’m trying to make an ability when u press a certain key u can see NPCs, not players, through objects.
I don’t really know where to start. I’ve seen people say to use viewport frames and billboard GUI, but I’m not exactly sure how viewport frames work.
Is there like a straight forward way to do this? Or is this actually pretty hard to do?
I know this has already been answered, but I wanted to inform you of another method. Another way you could probably approach this is with the use of ViewportFrames. This way, you get more scalability and customization with whatever you are trying to do. You would make a ViewportFrame the size of a script, make the background transparent, keep updating the camera to the same position as the one of the workspace, and just clone whatever characters you want to clone. Additionally, you could clone custom models to make it look differently, although it is up to you. @iluvtcr’s method also works greatly and is much easier to implement.
i redid alot of the code so just copy and paste it
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local VPF = script.Parent.ViewportFrame
VPF.CurrentCamera = workspace.CurrentCamera
wait(1)
local NormalMaterial = Enum.Material.Neon
local DefaultColor = script.DefaultColor
local TypeOfVision = script.IsHeat
local function MakeCharacter(model)
model.Archivable = true
local Clone = model:Clone()
for _,z in pairs(Clone:GetChildren()) do
if z:IsA("Script") or z:IsA("LocalScript") then
z:Destroy()
else if z:IsA("BasePart") then
z.Anchored = true
z.Material = NormalMaterial
z.Color = DefaultColor.Value
if z:IsA("MeshPart") then
z.TextureID = ""
end
if z:FindFirstChildWhichIsA("Decal") then z:FindFirstChildWhichIsA("Decal") :Destroy() end
else
if z:IsA("Accessory") then
for _,v in pairs(z:GetChildren()) do
if v:IsA("BasePart") then
v.Anchored = true
v.Material = NormalMaterial
v.Color = DefaultColor.Value
if v:IsA("MeshPart") then
v.TextureID = ""
else
if v:FindFirstChildWhichIsA("SpecialMesh") then
v:FindFirstChildWhichIsA("SpecialMesh").TextureId = ""
end
end
end
end
end
end
end
end
Clone.Humanoid.BreakJointsOnDeath = false
Clone.Parent = VPF
return Clone
end
local Humanoids = {}
local function GetHumanoids(part)
if part ~= char then
if part:FindFirstChildWhichIsA("Humanoid") then
table.insert(Humanoids,{part, MakeCharacter(part)})
else
for _,z in pairs(part:GetChildren()) do GetHumanoids(z) end
end
end
end
workspace.ChildAdded:Connect(function(c)
wait(1)
print(c:FindFirstChildWhichIsA("Humanoid"))
if c:FindFirstChildWhichIsA("Humanoid") and c ~= char then
table.insert(Humanoids,{c, MakeCharacter(c)})
end
end)
GetHumanoids(workspace)
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
game:GetService("RunService").RenderStepped:Connect(function()
if script.Parent.Enabled == false then return end
for i,z in pairs(Humanoids) do
local RealModule = z[1]
local CloneModule = z[2]
if not RealModule:FindFirstChildWhichIsA("Humanoid") or RealModule.Humanoid.Health <= 0 then CloneModule:Destroy() table.remove(Humanoids,i) continue end
if TypeOfVision.Value == false then params.FilterDescendantsInstances = {char,Humanoids} if workspace:Raycast(workspace.Camera.CFrame.Position,(RealModule.PrimaryPart.Position - workspace.Camera.CFrame.Position).unit * (workspace.Camera.CFrame.Position - RealModule.PrimaryPart.Position).magnitude,params) then for _,z in pairs(CloneModule:GetChildren()) do if z:IsA("BasePart") and z.Name ~= "HumanoidRootPart" then z.Transparency = 1 end end continue end end
for _,part in pairs(RealModule:GetChildren()) do
if part:IsA("BasePart") and part.Name ~= "HumanoidRootPart" then
CloneModule[part.Name].Transparency = 0
CloneModule[part.Name].Material = NormalMaterial
CloneModule[part.Name].Color = DefaultColor.Value
CloneModule[part.Name].CFrame = part.CFrame
else if part:IsA("Accessory") then
for _,v in pairs(part:GetChildren()) do
CloneModule[part.Name][v.Name].Transparency = 0
CloneModule[part.Name][v.Name].Material = NormalMaterial --if TypeOfVision.Value == true then CloneModule[part.Name][v.Name].Material = Enum.Material.Plastic else end
CloneModule[part.Name][v.Name].Color = DefaultColor.Value
CloneModule[part.Name][v.Name].CFrame = v.CFrame
end
end
end
end
end
end)
all enemies are in a folder…but i tried putting it in the workspace and still doesn’t work.
The enemy is just something i found in toolbox. Can it be the respawn script that it has that causes the problem?
Yea that’s the problem. It can detect them being added to workspace only, but since the respawn script doesn’t really remove the character, it just respawns it.
To work just make sure u do other way of respawning them if u are going to make respawn system