Through a local script, I made Touch and TouchEnded functions set up with a debounce. It's linked to a server script through a remote event if you're wondering why I'm using a local script. For some reason, when the character is touching the part, the functions get spammed.
Local Script:
local stuff = script.Parent
local bar = stuff:WaitForChild("Bar")
local point = workspace:WaitForChild("CapturePointC")
local model = point:WaitForChild("CircleThings")
local cappoint = model:WaitForChild("CapturePoint")
local mainscript = cappoint:WaitForChild("Capture")
local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("CapturePoints")
local point1 = events:WaitForChild("PointC")
local point1stop = events:WaitForChild("PointCStop")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local torso = char:WaitForChild("Hitbox")
local ifcap = char:WaitForChild("IfCapturing")
local touching = false
torso.Touched:Connect(function(hit)
if touching == false then
touching = true
if ifcap.Value == false then
if hit == cappoint then
print('ok')
stuff.Visible = true
point1:FireServer()
end
end
end
end)
torso.TouchEnded:Connect(function(hit)
if hit == cappoint then
touching = false
point1stop:FireServer()
print('ok2')
stuff.Visible = false
end
end)

2 comments
http://robloxdev.com/articles/Debounce
You shouldn’t handle touched event locally.