Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to detect if a frame is touching another frame?

So, i am trying to make a combat system that resembles undertale for a game i am working on

Whenever its the player's turn to attack, they will be greeted with a frame with different colors (green, yellow, orange, red) and a moving white frame, and depending on where they press Enter, the white moving frame will stop there and deal damage according to where it landed

Here's the problem though, how can i make it detect where the white attack frame lands?

I know this question is a little confusing, but if anyone could help i'd really appreciate it

1 answer

✓ Accepted answer

You don't have to detect if the frames are touching, you just have to take the position of the white frame. I'm assuming you want the highest damage to be in the middle and the lowest on the ends, so put your colors in a frame with the white one and then put this in a LocalScript in the main bar (change the damage system how you want):

local bar = script.Parent
local dmg
game:GetService("UserInputService").InputBegan:Connect(function(key, chat)
	if key.KeyCode = Enum.KeyCode.Return and not chat then
		if bar.Attack--[[the white frame]].Position.X > 0.5 then
			dmg = 100/bar.Attack.Position.X
		else
			dmg = bar.Attack.Position.X * 100
		end
	end
end)

something like that

1 comment

0

Thank you for the help! I appreciate it

This discussion is preserved as it was. New answers, comments, and votes are closed.