|
| 07 Aug 2014 02:48 PM |
how do I make it so when a player gets near an npc model, it highlights the model? and when the player gets too far, it removes it. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
sbk28
|
  |
| Joined: 15 Nov 2008 |
| Total Posts: 2528 |
|
|
| 07 Aug 2014 03:28 PM |
repeatedly loop and do
math.abs((npcposition - playerposition).Magnitude)
if that number is below a certain value then highlight your model
if its above then unhighlight |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2014 03:28 PM |
By 'highlights', do you mean inserting pointlights into the model? I could do that for you. |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2014 03:28 PM |
game:GetService("RunService").RenderStepped:connect(function() if (player.Character.Torso.Position-npc.Torso.Position).magnitude<=distance then --make it visible here else --make it invisible here end end)
You define player, npc, and distance. |
|
|
| Report Abuse |
|
|
sbk28
|
  |
| Joined: 15 Nov 2008 |
| Total Posts: 2528 |
|
|
| 07 Aug 2014 03:29 PM |
| ignore my math.abs i forgot magnitude will always be positive regardless of starting vectors |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2014 03:56 PM |
| by "Highlights" I mean the a SelectionBox, I don't mean it selects the whole model, I mean it selects all parts. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
BLOXLUA
|
  |
| Joined: 16 Mar 2013 |
| Total Posts: 453 |
|
|
| 07 Aug 2014 10:22 PM |
| It's not letting me post anything. |
|
|
| Report Abuse |
|
|
| |
|
BLOXLUA
|
  |
| Joined: 16 Mar 2013 |
| Total Posts: 453 |
|
|
| 07 Aug 2014 10:23 PM |
Alright, it's just not letting me post scripts apparently. It's not even long.
/wscfspFa |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2014 10:25 PM |
@lua
red line @ for A,A in pairs(MODEL:GetChildren()) do
|
|
|
| Report Abuse |
|
|
BLOXLUA
|
  |
| Joined: 16 Mar 2013 |
| Total Posts: 453 |
|
|
| 07 Aug 2014 10:25 PM |
Shoot! I forgot an end in the last one! (I am not even 100% sure I didn't make an error somewhere else, though)
/wNcYnT9S |
|
|
| Report Abuse |
|
|
BLOXLUA
|
  |
| Joined: 16 Mar 2013 |
| Total Posts: 453 |
|
|
| 07 Aug 2014 10:26 PM |
| "MODEL", "PLR", and "NPC" are not defined, define yourself. |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Aug 2014 10:28 PM |
still aint working :/ full localscript:
/yRYd1eY0 |
|
|
| Report Abuse |
|
|
BLOXLUA
|
  |
| Joined: 16 Mar 2013 |
| Total Posts: 453 |
|
|
| 07 Aug 2014 10:31 PM |
| The script is fairly easy, and I'm pretty sure I did it correctly. |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2014 10:31 PM |
tried making the local script more efficient but still not working :/
/RpJxuSmi |
|
|
| Report Abuse |
|
|
BLOXLUA
|
  |
| Joined: 16 Mar 2013 |
| Total Posts: 453 |
|
|
| 07 Aug 2014 10:34 PM |
| Try putting prints in places to debug it. I'm much too tired for that right now. |
|
|
| Report Abuse |
|
|
|
| 07 Aug 2014 10:49 PM |
local plr = Game.Players.LocalPlayer; local user = plr.Character; local npc = workspace.npc; function detect() if math.abs(npc.Torso.CFrame.x - user.Torso.CFrame.x) < 15 and math.abs(npc.Torso.CFrame.x - user.Torso.CFrame.y) < 15 and math.abs(npc.Torso.CFrame.z - user.Torso.CFrame.z) < 15 then local distance = (npc.Torso.CFrame.p - user.Torso.CFrame.p).magnitude; if distance < 30 then for highlight, children in pairs(npc:GetChildren()) do local selec = Instance.new("SelectionBox", workspace.CurrentCamera); selec.Adornee = children; selec.Color = BrickColor.new("Navy blue"); Game.Debris:AddItem(select, 0.5); end end end end while wait(0.035) do detect(); end |
|
|
| Report Abuse |
|
|