Touch not working?

  1. What do you want to achieve? Make a lava that stops when touches a part.

  2. What is the issue? The touch doesnt stop it.

local speed = 100

local gameRunning = game.Workspace.data.gameRunning.Value
local playersLeft = game.Workspace.data.playersLeft.Value
local endWall = script.Parent.Parent.room.endWall
local defSize = script.Parent.Size
local defCFrame = script.Parent.CFrame
local lavaSpeed = speed/100
wait(5)

endWall.Touched:Connect(function(hit)
	if hit.Name == "lava" then
		script.Parent.Size = defSize
		script.Parent.CFrame = defCFrame
		gameRunning = false
	end 
end)

while wait(0.01) do
	local gameRunning = game.Workspace.data.gameRunning.Value
	local playersLeft = game.Workspace.data.playersLeft.Value
	if gameRunning == false then elseif playersLeft == 0 then else 
		script.Parent.Size = Vector3.new(script.Parent.Size.X,script.Parent.Size.Y,script.Parent.Size.Z+lavaSpeed)
		script.Parent.CFrame = CFrame.new(script.Parent.CFrame.X,script.Parent.CFrame.Y,script.Parent.CFrame.Z+lavaSpeed/2)
	end	
end

According to the .Touched documentation, it says,

This event only fires as a result of physics movement, so it will not fire if the CFrame property was changed such that the part overlaps another part.

That means manually setting the CFrame in a script will not cause the .Touched event to fire.

As well, I would recommend using RunService instead of wait(0.01) for better performance.

So how can i make it trigger? Im thinking something with regions maybe? But i am not sure how to use those

Here is the link to the Region3 page on the Developer Hub if you want to use regions.

Thanks. Again character limit :confused:

No problem! Glad I was able to assist you. :slight_smile: