generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Magnitude and Highlights help!

Previous Thread :: Next Thread 
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
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
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
07 Aug 2014 02:50 PM
?
Report Abuse
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
07 Aug 2014 03:06 PM
1212
Report Abuse
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
07 Aug 2014 03:26 PM
Halp
Report Abuse
sbk28 is not online. 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
CLIMAXIMUS is not online. CLIMAXIMUS
Joined: 22 Jun 2012
Total Posts: 1738
07 Aug 2014 03:28 PM
By 'highlights', do you mean inserting pointlights into the model?
I could do that for you.
Report Abuse
IAmTheRolo is online. IAmTheRolo
Joined: 12 Nov 2013
Total Posts: 859
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 is not online. 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
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
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
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
07 Aug 2014 06:17 PM
...?
Report Abuse
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
07 Aug 2014 09:59 PM
pls?
Report Abuse
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
07 Aug 2014 10:12 PM
anyone?
no..?
Report Abuse
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
07 Aug 2014 10:21 PM
:c
Report Abuse
BLOXLUA is not online. BLOXLUA
Joined: 16 Mar 2013
Total Posts: 453
07 Aug 2014 10:22 PM
It's not letting me post anything.
Report Abuse
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
07 Aug 2014 10:22 PM
@blox

pasteb1n
Report Abuse
BLOXLUA is not online. 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
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
07 Aug 2014 10:25 PM
@lua

red line @
for A,A in pairs(MODEL:GetChildren()) do
Report Abuse
BLOXLUA is not online. 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 is not online. 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
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
07 Aug 2014 10:26 PM
nvm
Report Abuse
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
07 Aug 2014 10:28 PM
still aint working :/
full localscript:

/yRYd1eY0
Report Abuse
BLOXLUA is not online. 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
Cautionary is not online. Cautionary
Joined: 07 Jun 2012
Total Posts: 5647
07 Aug 2014 10:31 PM
tried making the local script more efficient but still not working :/

/RpJxuSmi
Report Abuse
BLOXLUA is not online. 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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image