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 |
|
|
|
| 30 Nov 2015 02:03 PM |
Something about...World-to-point or something?
Someone correct me. |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
| |
|
|
| 02 Dec 2015 01:15 PM |
| How could you possible get salty about me saying "damn" ? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 02 Dec 2015 01:20 PM |
| They really should filter you from this site |
|
|
| Report Abuse |
|
|
| |
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 02 Dec 2015 01:27 PM |
game:GetService("AntiForeverDevService").Enabled = true
Plz add this |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 30 Oct 2013 |
| Total Posts: 4440 |
|
| |
|
vlekje513
|
  |
| Joined: 28 Dec 2010 |
| Total Posts: 9057 |
|
| |
|