#Touched Events

9 messages · Page 1 of 1 (latest)

brittle crown
#

Hello So I am trying to remake super power training simulator and in the game you are able to punch stuff for example like stars and if your like in range you can punch the star you gain a multiplier but touched events are pretty buggy for me is there any other options? Here is my code

local Fist_Training = {}

Fist_Training.__index = Fist_Training

function Fist_Training.new(Req, Gain, Model)
    local self = {
        Requirment = Req,
        Gain = Gain,
        Model = Model,
        
        InZone = {}
    }
    
    return setmetatable(self, Fist_Training)
end


function Fist_Training:__Events__()
    self.Model.HitBox.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            if table.find(self.InZone, hit.Parent) or not hit.Parent:FindFirstChild("Humanoid") then return end
            table.insert(self.InZone, hit.Parent)
        end
    end)
    self.Model.HitBox.TouchEnded:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            table.remove(self.InZone, self.InZone[hit.Parent])
        end
    end)
end

function Fist_Training:__Init__()
    self:__Events__()
    while task.wait() do
        print(self.InZone)
    end
end


return Fist_Training

thanks!

tacit obsidian
#

its accurate af

#

or regions3

#

touched events are just worst af

blazing jungle
#

100% could not agree more

brittle crown
#
local Zone = require(game.ReplicatedStorage.Zone)




local BT_Zone = Zone.new(
    game.Workspace
)

print(BT_Zone.partEntered)

BT_Zone.partEntered:Connect(function()
    print("Player Enterd")
end)
--BTArea.new(game.Workspace.Model.Req, game.Workspace.Model.Gain, game.Workspace.Model):__Init__()
#

am I doing it correctly?