Every time it is rendered or not rendered it will spam
local Camera = game.Workspace.CurrentCamera
local Enemy = game.Workspace.Enemy
game:GetService('RunService').Stepped:Connect(function()
local Position, PlayerCanSee = Camera:WorldToScreenPoint(Enemy.Position)
if PlayerCanSee then
Enemy.Anchored = true
print("Rendered")
else
Enemy.Anchored = false
print("Not Rendered")
end
end)
Yes it is because you put local of the enemy is the model not the part of the enemy so the enemy won’t get anchored or anything Local Enemy = game.Workspace.Enemy
instead try (if the enemy you refer to is a model)
local Camera = game.Workspace.CurrentCamera
local Enemy = game.Workspace.Enemy
game:GetService('RunService').Stepped:Connect(function()
local Position, PlayerCanSee = Camera:WorldToScreenPoint(Enemy.Position)
if PlayerCanSee then
Enemy.PrimaryPart.Anchored = true
print("Rendered")
else
Enemy..PrimaryPart.Anchored = false
print("Not Rendered")
end
end)
Is that a ViewportFrame? If so, setting the part’s Anchored property to false wouldn’t cause it to move; you would need to do some weird combination of moving it into workspace and back into the viewportframe every frame to give the illusion of movement.
If it’s not a viewportframe, I sadly cannot help you
I had a brain fart lol, I found the problem. It’s this:
local Camera = game.Workspace.CurrentCamera
local Enemy = game.Workspace.Enemy
game:GetService('RunService').Stepped:Connect(function()
local Position, PlayerCanSee = Camera:WorldToScreenPoint(Enemy.Position)
if PlayerCanSee then
**Enemy.Anchored = false**
print("Rendered")
else
**Enemy.Anchored = true**
print("Not Rendered")
end
end)