[v3.0] GuiCollisionService - Gui collisions done right

Amazing feature! Would it be possible to have accurate UI image detection (where the image is not a square)?

That SOUNDS impossible I’d say. You could make some square hitboxes and offset it to the imagelabel.

Any tutorial? If there is no tutorial, then I am not using it.

Theres the documentation, you can use the documentation as a tutorial.

2 Likes

I’m getting this error:

ReplicatedStorage.GuiCollisionService:298: argument must be a boolean  -  Client - GuiCollisionService:298
Stack Begin  -  Studio
Script 'ReplicatedStorage.GuiCollisionService', Line 298 - function addCollider  -  Studio - GuiCollisionService:298
Script 'Players.killersuperlegend.PlayerGui.ScreenGui.ObstacleDodger.LocalScript', Line 7  -  Studio - LocalScript:7
Stack End

Why is that happening and how do I fix it?

Are you specifiying the 2nd argument (whether the collider is solid or not) in addCollider()?

What do you mean by that exactly? Oh and btw, I forgot to mention I managed to fix that kinda, but it gave me instead some other error, this is my code:

wait(3)
local GuiCollisionService = require(game.ReplicatedStorage.GuiCollisionService)

local group = GuiCollisionService.createCollisionGroup()

group:addCollider(script.Parent.Pipe1, true)
group:addCollider(script.Parent.Pipe1.PipeTop, true)
group:addCollider(script.Parent.Pipe1.PipeBottom, true)
group:addCollider(script.Parent.Pipe2, true)
group:addCollider(script.Parent.Pipe2.PipeTop, true)
group:addCollider(script.Parent.Pipe2.PipeBottom, true)
group:addHitter(script.Parent.Frame)

group:getHitter(1).CollidersTouched.Event:Connect(function(hits)
	group:getHitter(1).BackgroundColor3 = Color3.new(0.333333, 1, 0)
end)

group:getHitter(1).OnCollisionEnded.Event:Connect(function()
	group:getHitter(1).BackgroundColor3 = Color3.new(255,255,255)
end)
local player = game.Players.LocalPlayer
local RS = game:GetService("RunService")

RS.RenderStepped:Connect(function()
	script.Parent.Position = UDim2.new(0, player:GetMouse().X, 0, player:GetMouse().Y)
end)

And this is the other error I got after adding true after each instance in the addCollider()s:

ReplicatedStorage.GuiCollisionService:244: argument must be a table  -  Client - GuiCollisionService:244
Stack Begin  -  Studio
Script 'ReplicatedStorage.GuiCollisionService', Line 244 - function addHitter  -  Studio - GuiCollisionService:244
Script 'Players.killersuperlegend.PlayerGui.ScreenGui.ObstacleDodger.LocalScript', Line 12  -  Studio - LocalScript:12
Stack End

Pass in an empty table as the 2nd argument in addHitter(). The 2nd argument is a table of tweens which will play if the hitter collides with a collider, in your case, you don’t have any tweens to play, thus and empty table.

group:addHitter(script.Parent.frame, {})

1 Like

Thank you! It works, for the most part, the part now changes to green when it touches any of those parts, but also a Frame called Background gets affected, the whole thing moves with the cursor.
image

image

May this be the reason for that behavior? (script.Parent)

1 Like

Nope, I had it before, but I tried removing it but it the Background still moves with the cursor for some reason, I don’t really have any codes that does anything with the cursor

Edit: I SOMEHOW didn’t notice that in the code O_O, sorry!
The code works perfectly fine after removing that part of the code.

Thank you so much for helping me, your code is amazing!
Have an awesome day/night!

Is there a way to get the normal of the hit gui? If not, it should very well be a feature in a newer update.

1 Like

How can i detect which hitters that hits the collider?

How do I use this?! I’m just trying to detect which GUI a certain GUI is touching then return the touched GUI but my studio crashed using this module!

Same, it was also a huge pain in the butt to setup. It fires like ten times a frame when they are touching lol.

1 Like

I had to resort on a different function to utilize it anyway, the module does not like it when a frame gets destroyed with the event.

I’m getting ReplicatedStorage.Modules.GuiCollisionService:120: attempt to index nil with 'x' when I try to do if GUICollision.isInCore(ItemBox, script.Parent.Inventory) then

Awesome Module, except its a bit inaccurate.

Heres a video showing it, theres a beep sound when the red square in the player collides with a bullet.

Would like it to be fixed.

Yeah, me too! How could I fix it @jaipack17?

I was trying to figure out why the OnCollisionEnded event kept firing more and more times while the game was running and came across this code here. It’s creating a new listener event every frame and firing them all at once when the GUI exits another frame.

image
necropost but I wanted to put this out there for anyone who comes across this in the future