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 » Scripters
Home Search
 

Re: Need help! URGENT!

Previous Thread :: Next Thread 
fun4nerd is not online. fun4nerd
Joined: 30 Oct 2013
Total Posts: 4440
30 Nov 2015 12:59 PM
I need a example script that has a function() that fires when the player is looking at a part.
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
30 Nov 2015 02:03 PM
Something about...World-to-point or something?

Someone correct me.
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
30 Nov 2015 02:07 PM
Untested.


local Detected = nil
local Char = game.Players.LocalPlayer.Character

while wait() do
local ray = Ray.new(Char.Torso.Position,Char.Torso.CFrame.lookVector * 300)
local hit,position = game.Workspace:FindPartOnRayWithIgnoreList(ray,{Char})
if hit then
Detected = hit --'Hit' is the block that the ray found
end
end
Report Abuse
fun4nerd is not online. fun4nerd
Joined: 30 Oct 2013
Total Posts: 4440
30 Nov 2015 02:53 PM
THANKS A TON! Let me see what I can do with that example script.
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
30 Nov 2015 08:27 PM
Of course that would only work if there is a part in front of the torso. If you wanted to do it camera wise work with the CurrentCamera and put this code in a LocalScript.
Report Abuse
fun4nerd is not online. fun4nerd
Joined: 30 Oct 2013
Total Posts: 4440
02 Dec 2015 06:32 AM
Can you give another example script of what that will look like?
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
02 Dec 2015 12:50 PM
Uh, I'm not really able to figure out the results of what this will do. It could work how you want it to, but the ray might not be wide enough to cover the whole camera thing. Ehh idk.


local Detected = nil
local Char = game.Players.LocalPlayer.Character

while wait() do
local ray = Ray.new(Vector3.new(game.Workspace.CurrentCamera.CoordinateFrame),game.Workspace.CurrentCamera.CoordinateFrame.lookVector * 300)
local hit,position = game.Workspace:FindPartOnRayWithIgnoreList(ray,{Char})
if hit then
Detected = hit --'Hit' is the block that the ray found
end
end
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
02 Dec 2015 12:53 PM
or the more efficient: (untested)

local mouse = game.Players.LocalPlayer:GetMouse()

mouse.Move:connect(function()
if mouse.Target then
local hit = mouse.Target
print(hit.Name .. " is being looked at!")
end
end)
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
02 Dec 2015 12:55 PM
That wouldn't work at all. Mine doesn't work, but that doesn't do what he wants. Have you ever played Stop it Slender?
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
02 Dec 2015 12:57 PM
"I need a example script that has a function() that fires when the player is looking at a part. "

local function f(target)
print(target.Name)
end

local player = game.Players.LocalPlayer:GetMouse()

mouse.Move:connect(function()
if mouse.Target then
f(mouse.Target)
end
end)


That will call function f when a part is being looked at. How is that not what he asked for?
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
02 Dec 2015 12:59 PM
Have you ever played Stop it Slender?[2]


kinnis97 made a system where it checked if the CAMERA was looking at a part. Players could cheat by not moving their mouse' cursor over the Slenderman to avoid being killed. That's not what he wanted.
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
02 Dec 2015 01:00 PM
No I haven't played that game.

And by his simple one-sentence request, how should I assume that's what he wants?
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
02 Dec 2015 01:02 PM
He said when a player is 'looking' at a part. Not hovering it's mouse over a part. He would have specified. I can't get my script to work with the camera thing, it's weird.
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
02 Dec 2015 01:13 PM
If he's trying to detect if a part is simply on the screen....... That's pretty damn difficult.
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
02 Dec 2015 01:14 PM
Nice language.
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
02 Dec 2015 01:15 PM
How could you possible get salty about me saying "damn" ?
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
02 Dec 2015 01:18 PM
http://forum.roblox.com/Forum/ShowPost.aspx?PostID=80620879
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
02 Dec 2015 01:20 PM
If they didn't want people to say damn or ass they would have filtered them
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
02 Dec 2015 01:20 PM
They really should filter you from this site
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
02 Dec 2015 01:22 PM
How old are you, twelve?
Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
02 Dec 2015 01:27 PM
game:GetService("AntiForeverDevService").Enabled = true


Plz add this
Report Abuse
NovusTheory is not online. NovusTheory
Joined: 14 Oct 2009
Total Posts: 4532
02 Dec 2015 01:32 PM
Ladies stop fighting.

As for detecting it it's on the screen WorldToScreenPoint will give you a boolean if it's visible on the screen, Note "visible on screen" not looking at
Report Abuse
fun4nerd is not online. fun4nerd
Joined: 30 Oct 2013
Total Posts: 4440
03 Dec 2015 05:35 AM
Umm can someone give me an example that works. lol. Once I got an example I think I can figure the rest out.
Report Abuse
fun4nerd is not online. fun4nerd
Joined: 30 Oct 2013
Total Posts: 4440
04 Dec 2015 05:43 AM
bump
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
04 Dec 2015 07:16 AM
atan 2
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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