When a player drops a bomb in a "Capture" Area the player stops Capturing

Im making a sort of Capturing/Domination team game where to win you have to stay in the “Capture” zone for as long as possible to gain points for your team.

The issue is that the Capturing script works completely fine but whenever you drop any sort of bomb in the area it stops Capturing the area. The “In Game” solution is pretty simple because all you have to do is just exit and re-enter the “Capture” zone but i really don’t want players to get frustrated of doing this over time

Screenshots:
(Look at the “Capturing” leaderstat in the top right corner)

without bomb

with bomb

I’ve tried to make it so that when the bomb runs the “Destroy” function it makes the capturing leaderstat = 1 but i wasn’t able to identify the players leaderstats folder Because the workspace version of the player which most bombs and stuff use doesn’t contain the leaderstats folder.

Any suggestions would be great. :slight_smile:

2 Likes

Script inside of the “Capture” Part


local team = script.Parent 
local flag = script.Parent.Parent.Flag
local pole = script.Parent.Parent.Pole

function onTouch(hit) 
	local user = game.Players:GetPlayerFromCharacter(hit.Parent) 
	if user ~= nil then 
		user.leaderstats.Capturing.Value = 1
	end
end 

function offTouch(hit) 
	local user = game.Players:GetPlayerFromCharacter(hit.Parent) 
	if user ~= nil then 
		user.leaderstats.Capturing.Value = 0
	end
end 



script.Parent.Touched:Connect(onTouch)

script.Parent.TouchEnded:Connect(offTouch)

Script inside StarterPlayerScripts

local plr = game.Players.LocalPlayer

while wait(0.5) do
	if plr.leaderstats.Capturing.Value == 1 then
		plr.leaderstats.Points.Value += 1
	elseif plr.leaderstats.Capturing.Value == 0 then
		plr.leaderstats.Points.Value += 0
	end
end
1 Like

try using regions instead cause it has to be something about the bomb script ruining that

1 Like

Should I make it to where it detects if it’s a player touching it or not and if so then run the function?

no like use regions to check if the player is in the capture area

you can use a loop to constantly check if a player is in it or not

2 Likes

Wait so are regions the same thing as just looping to check for a player or is it something else


so basically theyre like boxes and you can use them to check what objects are inside of them

1 Like

How do you use the region3 for the part

Could you tell us if that happens when placing any type of item or object? Because if it only happens with the bomb, then I would recommend programming your own bomb using current methods, since I see that you use that type of old bomb from Roblox from 2010 that does not have texture and reflects the sky, these types of items use old and obsolete programming methods

1 Like

I’ve tried it with 2 different bombs but it’s probably for everything I drop I just haven’t tested anything else

By the way, if I remember correctly, I saw a programmer say that region3 was an obsolete method and that there was a better method, I think he was talking about overlaps params or something like that, anyway I don’t know if region3 can serve well in your situation, I don’t know about region3, but if it doesn’t work, also try overlaps params

1 Like

then try other objects to be sure

1 Like

I have a question, I have a way to fix it but it’s not really fixing it. Basically should I just divide the one big part into 20 small parts so that the bomb would only effect one of those 20 parts or should I not be lazy

I think the off touch function run when the bomb touch, I thin you can check if the touch part is player

1 Like

I feel like it wouldn’t be very good in terms of optimization, plus each part should have the script that gives points to whoever touches it, right? So I think the player would be earning several points for touching several parts

1 Like

It’s true I feel that the off touching event has something to do with it

1 Like

No I have that solved because all the part does is make the capture leaderstat = 1 and the 2nd script that I showed gives the points

The bug is for every droppable item btw

1 Like

I think we can add a fake variable name isplayer inside the startercharacterscript and then when the part got touched then check if the parent’s part have isplayer variable

2 Likes

then the programming of the bomb is not the problem, you should make a conditional that verifies that if what the capture touched is a part that is not a member of a character that does not intervene in anything in the code

1 Like