Hello! Apparently, This is My Second Post Here.
In my Game Recently, I’ve Been Trying to Make Region Notification Which a Ui Notifies the Player Once
They’ve Entered a Specific Region Throughout the Map. I’ve Been Using Touch and TouchEnded for Detecting If the Character Has Entered a Certain Region. I Find it More Efficient because Using Loop with Region3 Would Cause Performance Issues for The Client.
My Issue is TouchEnded Fired When The Player’s Character Jumps but In Studio It Didn’t Fire (Which is What I Wanted) The same goes with The Mobile Version of Roblox but Somehow The Website Version of Roblox Does This. I Don’t Know If This is an Engine Bug Though or It Could be My Code.
Here’s a Gif
https://i.gyazo.com/a432eb488c09b6163c1ef5941c3a26e5.mp4
As You Can See from The Gif Above, When I Entered That Region It Notifies Me. But Once I Jumped
It Notifies Me Again (Not What I Wanted).
Another Gif Example (Appstore Version)
https://i.gyazo.com/6fd6ede8d5f1f940f5c9be6905c3d04f.mp4
Here’s My Code
local Regions = workspace:WaitForChild("Regions"):GetChildren()
spawn(function()
for i , SelectedRegions in pairs(Regions) do
local RegionName = SelectedRegions:WaitForChild("Name")
SelectedRegions.Touched:Connect(function(thething) -- When An Object Touched / Entered The Part / Make Contact
if thething == Character.PrimaryPart and EnteringRegion ~= true then -- If The Part That Entered Is The Character
if CurrentRegion ~= RegionName.Value then -- If the region is not the current region
UponEnteringRegion(RegionName.Value) -- Has Entered Region
print("Player In Region")
if DoingVisuals ~= true then
spawn(function()
Visuals(CurrentRegion)
end)
end
end
end
end)
SelectedRegions.TouchEnded:Connect(function(thething) -- When An Object No Longer Touching / No longer inside part's Region
if thething == Character.PrimaryPart and EnteringRegion == true then -- When They Already In a Region
if CurrentRegion == RegionName.Value then -- If the region is the current region so when character can enter other regions without being in the same one
UponLeavingRegion(RegionName.Value) -- Has Left Region
print("Player Left Region")
end
end
end)
end
end)
I Would Appreciate Any Advice or Tips .