palk47
|
  |
| Joined: 07 May 2009 |
| Total Posts: 508 |
|
|
| 21 Nov 2012 09:38 PM |
Well, I copied a simple compass script from free models and moded it. I'm not the best with vectors, so I need some help. The script is supposed to make the image point to the direction of where the closest island is (Like in One Piece :d)
Here is my script:
---------------------- IQNORE/PROOF I DID NOTHING WRONG -------------------------- wait(0.5) local player = game.Players.LocalPlayer local character = game.Workspace:FindFirstChild(player.Name) if character == nil then script.Parent:Destroy() end local target = character.Torso
function findisland() findmag = 5000000 thetar = nil g = game.Workspace.Islands:GetChildren() for i = 1,#g do if (g[i].Position - target.Position).Magnitude < findmag then findmag = (g[i].Position - target.Position).Magnitude thetar = g[i] end end return thetar end ---------------------------------------------------------------------------
--Here is where the problem is:
repeat wait(0.01) local C = game.Workspace.CurrentCamera local tar = findisland()
local Direction = ( Vector2.new( tar.Position.x,tar.Position.z)- Vector2.new( C.Focus.x,C.Focus.z) ).unit
-- I'm having troubles with the part above here
script.Parent.Circle.N.Position = UDim2.new(0.5,-Direction.x*80,0.5,Direction.y*80) until script == nil |
|
|
| Report Abuse |
|
|
palk47
|
  |
| Joined: 07 May 2009 |
| Total Posts: 508 |
|
|
| 21 Nov 2012 09:39 PM |
| Oh, and yes. This is in a local script. If you need more information please ask me. |
|
|
| Report Abuse |
|
|
palk47
|
  |
| Joined: 07 May 2009 |
| Total Posts: 508 |
|
|
| 21 Nov 2012 09:45 PM |
| And oh yea, It's not C.Focus.x/C.Focus.z, it's C.CoordinateFrame.x/C.CoordinateFrame.z!!! |
|
|
| Report Abuse |
|
|
palk47
|
  |
| Joined: 07 May 2009 |
| Total Posts: 508 |
|
|
| 21 Nov 2012 09:50 PM |
| Sigh- Nevermind. I probably sound like a noob right now. |
|
|
| Report Abuse |
|
|
Octopus
|
  |
| Joined: 26 Feb 2008 |
| Total Posts: 460 |
|
| |
|
palk47
|
  |
| Joined: 07 May 2009 |
| Total Posts: 508 |
|
|
| 22 Nov 2012 06:22 PM |
| IT doesn't say anything. Everything in the script works, it's just that I'm having a hard time with the math. |
|
|
| Report Abuse |
|
|
nrscsy
|
  |
| Joined: 09 Nov 2012 |
| Total Posts: 465 |
|
|
| 22 Nov 2012 06:30 PM |
| If you describe how your math is faulty, then we will have it easier. |
|
|
| Report Abuse |
|
|
palk47
|
  |
| Joined: 07 May 2009 |
| Total Posts: 508 |
|
|
| 22 Nov 2012 06:55 PM |
| Ok. Should I give you a model to fix instead? You will probably not understand what i'm trying to do with just words. |
|
|
| Report Abuse |
|
|
palk47
|
  |
| Joined: 07 May 2009 |
| Total Posts: 508 |
|
|
| 22 Nov 2012 07:00 PM |
| Here's the model Btw: http://www.roblox.com/Broken-LogPose-item?id=98556943 |
|
|
| Report Abuse |
|
|