Hello
-
What do you want to achieve? I am currently making a CTP system of my own and I want to detect if a player has been on the Point part for X seconds for the capture to be success, and for it to cancel if the player leaves before the X seconds
-
What is the issue? I tried using variables like local InProcessOfCapture to determine the process, and if the variable was true and the TouchEvent ended while the player was capturing, it would be cancelled and the Point would return to its previous unclaimed state
-
What solutions have you tried so far? I looked across da forum and found nothing related to my matter, I couldn’t think of another way to solve my issue other than touchended
local inProcessOfCapture = false
local PointA = script.Parent
local Debounce = false
PointA.Touched:connect(function(hit)
if not game.Players:GetPlayerFromCharacter(hit.Parent) then return end
local char = hit.Parent
local MainPlayerTeam = char.TeamColor
if MainPlayerTeam == BrickColor.new("Really blue") then
if Debounce == false and PointA.BrickColor == BrickColor.new("Really red") or PointA.BrickColor == BrickColor.new("Institutional white") then
script.Parent.GUILOL.Enabled = true
Debounce = true
local inProcessOfCapture = true
wait(3)
PointA.BrickColor = BrickColor.new("Really blue")
script.Parent.GUILOL.Enabled = false
local inProcessOfCapture = false
Debounce = false
end
elseif MainPlayerTeam == BrickColor.new("Really red") then
if Debounce == false and PointA.BrickColor == BrickColor.new("Really blue") or PointA.BrickColor == BrickColor.new("Institutional white") then
script.Parent.GUILOL.Enabled = true
local inProcessOfCapture = true
Debounce = true
wait(3)
PointA.BrickColor = BrickColor.new("Really red")
script.Parent.GUILOL.Enabled = false
local inProcessOfCapture = false
Debounce = false
end
end
PointA.TouchEnded:connect(function(hit)
if hit.Parent == char then
if inProcessOfCapture == true then
Debounce = false
PointA.BrickColor = BrickColor.new("Institutional white")
script.Parent.GUILOL.Enabled = false
end
end
end)
end)
It was step on part to instantly capture (not including the wait(5)) before I added the Touch and TouchEnded events, were these wrong functions