|
| 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 |
|
|
| |
|
| |
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 27 Jul 2011 07:22 PM |
| Too advanced for meh, sorry x.x |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 27 Jul 2011 07:25 PM |
| Thank you, that's english. That was geek english. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 27 Jul 2011 07:34 PM |
wat
That part looks fine, now Y U BOTHERIN ME D: |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 27 Jul 2011 07:38 PM |
So I can do this:
while wait() do targ = findTarg() script.Object.Value = targ.pln |
|
|
| Report Abuse |
|
|
| |
|