Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How would I make it so when a player looks away from a npc, then the npc disappears?

Asked by
lilzy7 68
3 years ago

So, what i'm trying to do is there is a npc, and when it is not visible on the camera anymore, then it will disappear. I tried raycasting, but I don't know where to start. Please help on what I should probably use, to achieve my goal. Thank you!

2 answers

Log in to vote
2
Answered by
raid6n 2196 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

Yes, scripting helpers is NOT a request site, but I thought this was a good question.

You could use WorldToScreenPoint) to see if the parts isn't in the player's view.

Code:

local withinScreenBounds = Camera:WorldToScreenPoint(part.Position)

if not withinScreenBounds then

end
0
I get the property you mean, but I don't get why you use two variables and what withinScreenBounds means. lilzy7 68 — 3y
0
My apologies, I didn't notice that I added an addition variable. Also, withinScreenBounds is just a variable. raid6n 2196 — 3y
Ad
Log in to vote
-1
Answered by
ZIRFAL3 17
3 years ago
Edited 3 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

U could make a script ina a part, and ad a click detector (u can do this with UI, but i dont know how)

script.Parent.ClickDetector.MouseHoverLeave:connect(function() -- Detect Mouse Hover Leave.
script.Parent.Parent:Destroy() -- Destroy Parent.
end)

maybe (DownVotes come fast XD)

0
does that giant "-1" mean i did it wrong? XD ZIRFAL3 17 — 3y
0
yez lilzy7 68 — 3y
0
actually means someone down voted your answer, in this case bc it don't have a explanation Leamir 3138 — 3y
0
oh ZIRFAL3 17 — 3y

Answer this question