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

I think we can do something like this

--Remember to add IsPlayer variables inside the character


function onTouch(hit) 
	--your things
end 

function offTouch(hit) 
	--your things
end 

script.Parent.Touched:Connect(function(hit)
	if hit.parent:FindFirstChild("IsPlayer") then
		onTouch(hit)
	end
end)

script.Parent.TouchEnded:Connect(function(hit)
	if hit.parent:FindFirstChild("IsPlayer") then
		onTouch(hit)
	end
end)
2 Likes

You think I can replace the IsPlayer with humanoid

I make the IsPlayer in startercharacterscripts a number value right

yeah, you can, but if you want to add bots into your game then use IsPlayer, and remember use FindFirstChildWhichIsA(“Humanoid”), bc there’s some avatar item name Humanoid

1 Like

the important thing is that the name is isplayer

1 Like

everything you want, bc we just check the name

1 Like

It does the same thing :sad: Extra characters hhshsjsw

I feel like the solution to the problem is very simple, that should have worked, but there are still methods to try, let me think of one.

1 Like

You should put prints in the code to get to the root of the problem, start with something like this

function offTouch(hit) 
	local user = game.Players:GetPlayerFromCharacter(hit.Parent) 
	if user ~= nil then 
		user.leaderstats.Capturing.Value = 0
    elseif user == nil then
        print("its nil")
	end
end 
1 Like

Wait I have an error from the previous method. It says “Attempt to index nil with ‘FindFirstChild’”

Line 27 jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

fix it and then tell me the rest

1 Like

It didn’t say user == nil but now it’s like selecting my body parts and trying to find the “IsPlayer”

How can I make it search for the IsPlayer in just the workspace.Player

Guys I gotta go to bed I might repost this tomorrow unless you guys can continue tomorrow.

Don’t worry, no problems, tomorrow we continue

1 Like

Good night ………………………………………………….

good night---------------------

1 Like

Have you still not solved the problem?

1 Like

No I just got home my bad …………………,.,