Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

BasePart.Touched event not firing?

I need to make this script so that if a part touches the expanding red ball, it will 'liquify'. I put in a print command, but it only fires if it comes in contact with a player. Here's the code.

script.Parent.Touched:Connect(function(hit)
	print("Liquify touch")
	if not hit:IsDescendantOf(workspace.ReactorCore) then
		local humanoid = hit.Parent:FindFirstChild("Humanoid")
		
		if humanoid ~= nil then
			local flame = Instance.new("Fire", hit.Parent.HumanoidRootPart)
			flame.Color = script.Parent.Color
			wait(1)
			
			for _,v in pairs(hit.Parent:GetChildren()) do
				if v:IsA("BasePart") then
					v.BrickColor = BrickColor.new("Really red")
					v.Material = Enum.Material.Neon
				end
			end
			wait(1)
			
			local explosion = Instance.new("Explosion", workspace)
			explosion.Position = hit.Parent.HumanoidRootPart.Position
			humanoid.Health = 0
			
		elseif humanoid == nil then
			print("Melting")
			hit.BrickColor = script.Parent.BrickColor
			hit.Material = Enum.Material.Neon
			wait(2)
			hit.Anchored = false
		end
	end
end)

If anyone can tell me why it isn't working, I'd be very grateful.

  • JB_SuperGamer

UPDATE: I have discovered that it will only melt unanchored parts. Does anyone know the cause of this?

3 comments

0

The code should work as expected. Granted you never check if the hit was indeed the red ball. The red ball is not a descendant of ReactorCore, right?

0

is this a localscript or normal script? since touched doesnt work on localscripts

0

No, the script is just a normal script, and no, the red ball is a descendant of ReactorCore

3 answers

did you by any chance turn CanTouch to false

2 comments

0

Nope, all of the parts are set to CanTouch true

0

the script should work and is the ball descendant of reactorcore

This maybe worth a try. Try changing hit to plr

Make sure you change all the hit to the plr Hope this works!!

1 comment

0

Tried, had no difference

I am quite confused as to why this is happening. You can follow this link to a Roblox place, because in that place it works fine.

3 comments

0

(Set to Private, couldn't check)

0

sorry, updating now!

0

alright, try it now.

This discussion is preserved as it was. New answers, comments, and votes are closed.