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: Weird, won't work.

Previous Thread :: Next Thread 
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
27 Jul 2011 06:55 PM
function findTarg()
main = game.Players.LocalPlayer.Character.Plane.MainParts.Main
lockSensitivity = 0.3
local targ = {pln=nil;dist=math.huge}
local maxDist = 1500
for _,v in pairs(game.Workspace:GetChildren()) do
if ((v:findFirstChild("Humanoid")) and (v ~= game.Players.LocalPlayer.Character) and (v:findFirstChild("Plane"))) then
player = game.Players:GetPlayerFromCharacter(v)
if ((player.TeamColor ~= game.Players.LocalPlayer.TeamColor) and (v.Humanoid.Health > 0)) then
if (v.Plane.MainParts:findFirstChild("Main")) then
local dist = (main.Position-v.Plane.MainParts.Main.Position).magnitude
if (dist <= maxDist) then
local hisLV = (CFrame.new(v.Plane.MainParts.Main.Position,main.Position)*CFrame.Angles(0,math.rad(180),0)).lookVector
local myLV = main.CFrame.lookVector
local diff = (hisLV-myLV).magnitude
if ((diff <= lockSensitivity) and (dist < targ.dist)) then
targ.pln,targ.dist = v.Plane.MainParts.Main,dist
end
end
end
end
end
end
return targ
end


while true do
wait()
findTarg()
if targ.pln ~= nil then
script.Parent.Main.Locked.Value = true
script.Parent.Main.Object.Value = targ.pln
m = Instance.new("Message",game.Players.LocalPlayer.PlayerGui)
m.Text = "Whats uppp!"
wait(1)
m:Remove()
elseif targ.pln == nil then
script.Parent.Main.Locked.Value = false
script.Parent.Main.Object.Value = nil
end end






Output says nothing. The message isn't created
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
27 Jul 2011 06:59 PM
Bawmp
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
27 Jul 2011 07:06 PM
Halp
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
27 Jul 2011 07:09 PM
I am too lazy to look through that, and what it is suppose to do in the first place :3
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
27 Jul 2011 07:17 PM
A missile lock script
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
27 Jul 2011 07:21 PM
"if targ.pln ~= nil then"

The variable "targ" is local to the function findTarg. The function does return "targ" to the function call, but you don't have anything getting that return value from the function call.

Lrn2logic
Report Abuse
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
27 Jul 2011 07:22 PM
Too advanced for meh, sorry x.x
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
27 Jul 2011 07:22 PM
Ok now in english please
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
27 Jul 2011 07:24 PM
That was English.

If you want the simple solution, here:

targ = findTarg()

Find where that could apply in your script, figure out what was wrong, and be happy.
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
27 Jul 2011 07:25 PM
Thank you, that's english. That was geek english.
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
27 Jul 2011 07:29 PM
What about this part:

targ.pln,targ.dist = v.Plane.MainParts.Main,dist


Can I use that?
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
27 Jul 2011 07:30 PM
crazyvegetable?
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
27 Jul 2011 07:34 PM
wat

That part looks fine, now Y U BOTHERIN ME D:
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
27 Jul 2011 07:35 PM
Can I access it later though?
I need help that's why :D
Now you also turn that frown upside down :P
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
27 Jul 2011 07:36 PM
Yes, you can access it later, the same exact table that you're editing there is passed to the function call.
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
27 Jul 2011 07:38 PM
So I can do this:

while wait() do
targ = findTarg()
script.Object.Value = targ.pln
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
27 Jul 2011 07:39 PM
Yes.
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