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: Making efficient code?

Previous Thread :: Next Thread 
drslicendice is not online. drslicendice
Joined: 05 Mar 2011
Total Posts: 18737
08 Mar 2015 02:51 PM
Here is the code.. I am making a animatronic game. I am trying to make the animatronics freeze when they get viewed by the camera, and this is what I have on mind. The loops are kind of laggy...

while true do

Cameras = {script.Parent.CamA, script.Parent.CamB, script.Parent.CamC}
Cam = Cameras[math.random(1,#Cameras)]
game.Workspace.Camera2.Value = Cam

for i = 1,25,1 do

for i,v in pairs(game.Players:GetChildren()) do
if v.Character:FindFirstChild("Chest") then

local ray = Ray.new(Cam.CFrame.p,(v.Character.Torso.CFrame.p - Cam.CFrame.p).unit * 500)
local ignore = script.Parent
local hit, position = workspace:FindPartOnRay(ray, ignore)

local tor = v.Character.Torso
local mag = ((position - tor.Position).Magnitude)

if hit.Name == "HitBox" then

tor.Parent.Humanoid.WalkSpeed = 0
for i,v in pairs(tor.Parent:GetChildren()) do
if v:IsA("BasePart") then
v.Anchored = true
end end

else
tor.Parent.Humanoid.WalkSpeed = 16
for i,v in pairs(tor.Parent:GetChildren()) do
if v:IsA("BasePart") then
v.Anchored = false
end end end end end wait(0.1) end end
Report Abuse
CrescentJade is not online. CrescentJade
Joined: 07 Jul 2010
Total Posts: 5494
08 Mar 2015 02:54 PM
Your gonna need multiple raysfrom the camera
Report Abuse
drslicendice is not online. drslicendice
Joined: 05 Mar 2011
Total Posts: 18737
08 Mar 2015 02:56 PM
How much?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
08 Mar 2015 02:57 PM
Frankly, I wouldn't use rays at all. I would use Stravant's ScreenSpace module to see if the object is on screen, and then... oh wait... And THEN I would raycast, if it was on screen.
Report Abuse
drslicendice is not online. drslicendice
Joined: 05 Mar 2011
Total Posts: 18737
08 Mar 2015 02:58 PM
Okay, thanks!!!
Report Abuse
drslicendice is not online. drslicendice
Joined: 05 Mar 2011
Total Posts: 18737
08 Mar 2015 03:02 PM
Hmm.. How does it work?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
08 Mar 2015 03:04 PM
It converts 3D to 2D space and vise-versa.
Report Abuse
drslicendice is not online. drslicendice
Joined: 05 Mar 2011
Total Posts: 18737
08 Mar 2015 03:08 PM
Sorry for asking so many questions, but how do I use it? I know how to run a module script, but this script doesn't really give any instructions on how to use it correctly.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
08 Mar 2015 03:12 PM
I can help you tomorrow. Now, I am very tired.
Report Abuse
drslicendice is not online. drslicendice
Joined: 05 Mar 2011
Total Posts: 18737
08 Mar 2015 03:15 PM
Tomorrow is Monday :T
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