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: FPS

Previous Thread :: Next Thread 
GUESTHAXX is not online. 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 is not online. GUESTHAXX
Joined: 16 Apr 2012
Total Posts: 3370
14 Nov 2012 04:25 PM
bump
Report Abuse
zars15 is not online. 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 is not online. mtc11
Joined: 05 Dec 2010
Total Posts: 141
14 Nov 2012 04:29 PM
hmmm
Report Abuse
GUESTHAXX is not online. 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
KesinTheCake is not online. KesinTheCake
Joined: 04 Nov 2012
Total Posts: 200
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 is not online. 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
KesinTheCake is not online. KesinTheCake
Joined: 04 Nov 2012
Total Posts: 200
14 Nov 2012 05:02 PM
thatonebit = workspace:findFirstChild(script.Parent.Parent.Name)


my bad
Report Abuse
KesinTheCake is not online. KesinTheCake
Joined: 04 Nov 2012
Total Posts: 200
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 is not online. 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
KesinTheCake is not online. KesinTheCake
Joined: 04 Nov 2012
Total Posts: 200
14 Nov 2012 05:09 PM
if you'd be so kind.
Report Abuse
GUESTHAXX is not online. 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
KesinTheCake is not online. KesinTheCake
Joined: 04 Nov 2012
Total Posts: 200
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 is not online. 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
KesinTheCake is not online. KesinTheCake
Joined: 04 Nov 2012
Total Posts: 200
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
KesinTheCake is not online. KesinTheCake
Joined: 04 Nov 2012
Total Posts: 200
14 Nov 2012 08:55 PM
Oh wait, change val to 1 :L

my bad.
Report Abuse
GUESTHAXX is not online. GUESTHAXX
Joined: 16 Apr 2012
Total Posts: 3370
14 Nov 2012 09:02 PM
Thanks so very much!
Report Abuse
KesinTheCake is not online. KesinTheCake
Joined: 04 Nov 2012
Total Posts: 200
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 is not online. 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
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