GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 14 Nov 2012 04:02 PM |
Basically what I'm trying to do is make a GUI's Frame appear when your in FPS mode..
local Camera = workspace.CurrentCamera while wait() do if script.Parent.Parent.MaskOn.Value == true and Camera.Focus == 1 then script.Parent.Parent.Frame.Visible = true elseif script.Parent.Parent.MaskOn.Value == false then script.Parent.Parent.Frame.Visible = false end end
Output is empty, so I'm guessing its this part?:
Camera.Focus == 1 then |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
| |
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 14 Nov 2012 04:27 PM |
| What, camera focus set as 1? Wasn't focus a CFrame value? |
|
|
| Report Abuse |
|
|
mtc11
|
  |
| Joined: 05 Dec 2010 |
| Total Posts: 141 |
|
| |
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 14 Nov 2012 04:32 PM |
Yes, I think. But I don't want to set a new parent for the camera.
Just want to make a Gui's Frame become visible when your in FPS mode and vice versa.. |
|
|
| Report Abuse |
|
|
|
| 14 Nov 2012 04:34 PM |
--localscript in a persons' backpack
local val = 1 --max distance cam has to be from head for ui to appear function calcdist() local n = vector3.new(workspace.CurrentCamera.CoordinateFrame.x,workspace.CurrentCamera.CoordinateFrame.y,workspace.CurrentCamera.CoordinateFrame.z) thatonebit = workspace:findFirstChild(script.Parent.Parent) if thatonebit then head = thatonebit:findFirstChild("Head") if head then if (n-head.Position).magnitude <= val then --code for UI to appear here end end end end
calcdist() |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 14 Nov 2012 05:00 PM |
local val = 1 --max distance cam has to be from head for ui to appear function calcdist() while wait() do local n = vector3.new(workspace.CurrentCamera.CoordinateFrame.x,workspace.CurrentCamera.CoordinateFrame.y,workspace.CurrentCamera.CoordinateFrame.z) thatonebit = workspace:findFirstChild(script.Parent.Parent) if thatonebit then head = thatonebit:findFirstChild("Head") if head then if (n-head.Position).magnitude <= val then script.Parent.Parent.Frame.Visible = true elseif script.Parent.Parent.MaskOn.Value == false then script.Parent.Parent.Frame.Visible = false end end
calcdist()
output is eof
Samething from output no matter how many ends there is. Is this the only way to do this? |
|
|
| Report Abuse |
|
|
|
| 14 Nov 2012 05:02 PM |
thatonebit = workspace:findFirstChild(script.Parent.Parent.Name)
my bad
|
|
|
| Report Abuse |
|
|
|
| 14 Nov 2012 05:02 PM |
also
while wait() do calcdist() end
try that instead perhaps? Dunno if that really matters, but I know that works fosho. |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 14 Nov 2012 05:08 PM |
Still nothing, cleared the output though..
Maybe I should of put this:
StarterGui >ScreenGui >>MaskOn (bool value) >>Frame >>>LocalScript
(Script, nothing happening though.)
local val = 1 --max distance cam has to be from head for ui to appear function calcdist() local n = vector3.new(workspace.CurrentCamera.CoordinateFrame.x,workspace.CurrentCamera.CoordinateFrame.y,workspace.CurrentCamera.CoordinateFrame.z) thatonebit = workspace:findFirstChild(script.Parent.Parent.Name) if thatonebit then head = thatonebit:findFirstChild("Head") if head then if (n-head.Position).magnitude <= val then while wait() do if script.Parent.Parent.MaskOn.Value == true and Camera.Focus == 1 then script.Parent.Parent.Frame.Visible = true elseif script.Parent.Parent.MaskOn.Value == false then script.Parent.Parent.Frame.Visible = false end end end end
while wait() do calcdist() end
Should I upload the GUI into a model? |
|
|
| Report Abuse |
|
|
| |
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 14 Nov 2012 05:41 PM |
Here:
http://www.roblox.com/Model-643-item?id=97773534 |
|
|
| Report Abuse |
|
|
|
| 14 Nov 2012 05:54 PM |
local val = 1 --script goes in backpack btw. HAS to. function calcdist() local n = Vector3.new(workspace.CurrentCamera.CoordinateFrame.x,workspace.CurrentCamera.CoordinateFrame.y,workspace.CurrentCamera.CoordinateFrame.z) thatonebit = workspace:findFirstChild(script.Parent.Parent.Name) if thatonebit then head = thatonebit:findFirstChild("Head") if head then print((n - head.Position).magnitude) if (n - head.Position).magnitude <= val then print(1) local gmask = script.Parent.Parent.PlayerGui.Gasmask gmask.MaskOn.Value = true gmask.Frame.Visible = true else local gmask = script.Parent.Parent.PlayerGui.Gasmask gmask.MaskOn.Value = false gmask.Frame.Visible = false end end end end
while wait() do calcdist() end
|
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 14 Nov 2012 08:35 PM |
Thanks... Only problem is that it is constantly setting the MaskON value to true...
Now if I make a simple change...
local val = 1 --script goes in backpack btw. HAS to. function calcdist() local n = Vector3.new(workspace.CurrentCamera.CoordinateFrame.x,workspace.CurrentCamera.CoordinateFrame.y,workspace.CurrentCamera.CoordinateFrame.z) thatonebit = workspace:findFirstChild(script.Parent.Parent.Name) if thatonebit then head = thatonebit:findFirstChild("Head") if head then print((n - head.Position).magnitude) if (n - head.Position).magnitude <= val then print(1) local gmask = script.Parent.Parent.PlayerGui.Gasmask if gmask.MaskOn.Value = true then gmask.Frame.Visible = true else local gmask = script.Parent.Parent.PlayerGui.Gasmask elseif gmask.MaskOn.Value = false then gmask.Frame.Visible = false end end end end
while wait() do calcdist() end
Output:
20:31:05 - Players.Player1.Backpack.Player:12: 'then' expected near '='
Probably something simple put that output error throws me off. |
|
|
| Report Abuse |
|
|
|
| 14 Nov 2012 08:54 PM |
local val = 100 --script goes in backpack btw. HAS to. local actualdist = 400 local fakevalue = false function calcdist() local n = Vector3.new(workspace.CurrentCamera.CoordinateFrame.x,workspace.CurrentCamera.CoordinateFrame.y,workspace.CurrentCamera.CoordinateFrame.z) thatonebit = workspace:findFirstChild(script.Parent.Parent.Name) if thatonebit then head = thatonebit:findFirstChild("Head") if head then print((n - head.Position).magnitude) actualdist = (n - head.Position).magnitude if actualdist <= val and fakevalue == false then fakevalue = true print(1) local gmask = script.Parent.Parent.PlayerGui.Gasmask gmask.MaskOn.Value = true gmask.Frame.Visible = true elseif actualdist > val and fakevalue == true then fakevalue = false local gmask = script.Parent.Parent.PlayerGui.Gasmask gmask.Frame.Visible = false gmask.MaskOn.Value = false end end end end
while wait() do calcdist() end |
|
|
| Report Abuse |
|
|
|
| 14 Nov 2012 08:55 PM |
Oh wait, change val to 1 :L
my bad. |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
| |
|
|
| 14 Nov 2012 09:05 PM |
| Absolutely! Should be noted though, the mask being visible isn't dictated by whether or not the MaskOn value is. |
|
|
| Report Abuse |
|
|
GUESTHAXX
|
  |
| Joined: 16 Apr 2012 |
| Total Posts: 3370 |
|
|
| 14 Nov 2012 09:13 PM |
| Oh ok, ill be keeping that in mind, thanks. |
|
|
| Report Abuse |
|
|