Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to detect if a frame is touching another frame?

Asked by 2 years ago

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

Log in to vote
0
Answered by
boredlake 256 Moderation Voter
2 years ago

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

0
Thank you for the help! I appreciate it lolmarios2647 46 — 2y
Ad

Answer this question