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
 

Is there a way to tell if two GUIs are touching?

Previous Thread :: Next Thread 
HillBilly9843 is not online. HillBilly9843
Joined: 05 Jan 2009
Total Posts: 7870
17 Jul 2014 03:18 PM
I looked at the wiki article, but I didnt really undertand what to use and what not to use, because of the whole rectangle thing. I was hoping someone, if they didnt mind, could dumb it down for me.
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
17 Jul 2014 03:22 PM
Ok, since roblox didnt come up with a touched function, we have to make it ourselves.

local function Collide(gui1,gui2)
return ((gui1.Position.x < gui2.Position.x+gui2.Size.x and gui1.Position.x+gui1.Size.x > gui2.Position.x) and (gui1.Position.y > gui2.Position.y and gui1.Position.y < gui2.Position.y+gui2.Size.y)) or ((gui2.Position.x < gui1.Position.x+gui1.Size.x and gui2.Position.x + gui2.Size.x >gui1.Position.x) and (gui2.Position.y > gui1.Position.y and gui2.Position.y < gui1.Position.y+gui1.Size.y))
end


See this Code.

So lets start

It checks for the position of gui one, the top left.
But sometimes things collide from the right, right?
so we need to check that.
The way is adding the x size.
For getting the bottom, you add the y size.

so, with it checking all of the sides, if gui2 is more than it, in all ways, it will check for being collided from the middle and onwards.

Hope this helps!
Report Abuse
MrTucan1996 is not online. MrTucan1996
Joined: 19 Aug 2009
Total Posts: 5994
17 Jul 2014 03:24 PM
Wiki usually never helps with stuff.

If you need help just ask Kev lol.
Report Abuse
HillBilly9843 is not online. HillBilly9843
Joined: 05 Jan 2009
Total Posts: 7870
17 Jul 2014 03:28 PM
thanks im going to try that right now
Report Abuse
HillBilly9843 is not online. HillBilly9843
Joined: 05 Jan 2009
Total Posts: 7870
17 Jul 2014 03:37 PM
wait, but what if the gui you want to know is touching something doesnt have anything there to touch it yet

im trying to make a GUI dartboard that only counts bullseyes, and i have everything done but the part where it checks if the dart touches the bullseye. the script creates a 5 by 5 gui frame, and puts it on the board. the thing it needs to hit is 30 by 30. what would i have to put into the 30 by 30 piece to check, say every 1 second, if a gui named "dart" appeared inside of it.
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
17 Jul 2014 05:32 PM
I dont really understand what your saying, but, if you mean the bullets are being created, then maybe do something like this? :P

while wait() do
for i,v in pairs(WHERETHEBULLETSARECREATED:GetChildren()) do
if Collide(v, thetarget) then
print'colliding!'
end
end
end
Report Abuse
KEVEKEV77 is not online. KEVEKEV77
Joined: 12 Mar 2009
Total Posts: 6961
17 Jul 2014 05:33 PM
May I see ur place?
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