My bullet breaks the block but it won't turn off the light

  1. What do you want to achieve?
    I want the bullet to break the block and remove the light

  2. What is the issue?
    I have no idea how to modify the script so that the bullet turns off the light.

  3. What solutions have you tried so far?
    I tried to put a “Parent” but failed

--
local _glass = script.Parent
local point = script.Parent.PointLight

function touch(other)
	local hum = other.Parent:FindFirstChild("NewBullet")
	if hum then
		point.Enabled = false
	end
end

_glass.Touched:Connect(touch)

adadad11121 dasda11123 1CAPTURA

locations:

_glass = workspace

NewBullet = ReplicatedStorage.Misc.Proyectiles.NewBullet

script = in _glass

it would be highly appreciated

Why are you trying to get the parent to find the newbullet, you could simple write other:FindFirstChild("NewBullet").

Also, if that doesn’t work you could try optimizing some stuff.

more info

https://gyazo.com/b3e42f08cee1e0e87942db8d9ee6f60d
other image

the same does not work the script

I don’t think .Touched work with anchored parts/when your bullet hits an anchored part. You can try raycast or just turn off the light after a certain amount of time.

To make the bullet hit the block, the touched function atleast fires when both parts (the part that has a touched function and the one who made in contact) intersect or make in contact.

Anyways your script is right but the only thing wrong is that your getting the parent of the part that started the fire of the touched function so you should instead write object instead of object.Parent.

Maybe you should make it like this:
Add a humanoid there, and get the .Death event.

1 Like

Where does the part breaking occur? The code you provided only appears to be for the light.

You should put the code to turn off the light in the same code as the breaking of the part if you want them to happen at the same time in response to the same event.

Also, when the bullet is fired, it will not be in that replicated storage folder anymore, so be careful with looking for a child inside its parent, as the parent will not be the Projectiles folder.

oh thx :cold_face: :call_me_hand:

1 Like