Basically I want to find a way to make my script more efficient when detecting if an object hits the part above the basketball rim.
There is a part that detects if the basketball touches the top of the rim.
OnTop Code: (Sets the OnTop value to true if it touches the top of the rim.)
local brick = script.Parent
local OnTop = script.Parent.Parent.OnTop
brick.Touched:Connect(function(hit)
if hit.Name == "Ball" then
OnTop.Value = true
wait(1)
OnTop.Value = false
end
end)
Goal Code: (Basically if it goes through the basket and checks if the OnTop value is set to true)
while not _G.AeroServer do wait() end
local HoopModule = _G.AeroServer.Modules.HoopModule
local hoop = script.Parent.Parent
local ontop = hoop.OnTop
local brick = script.Parent
brick.Touched:Connect(function(hit)
if hit.Name == "Ball" and ontop.Value == true then
HoopModule:Hit(hoop, script) --Basically makes a part flash green
end
end)
This picture below shows where everything is located.
Right now, the scripts work okay, but there are a couple instances where the flashing green part won't light up.
Thanks, LukeGabrieI

2 comments
Just combine both scripts into one script, you don't need two touched events!
I mean you don't need two touched events on the same part.