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

(Solved)Can not I disable a script properly?

Hi, my problem is that when the floor deactivates the script when it gets on the car it keeps deactivating the script, it does not activate it once and then it is deactivated, because the cohce is touching the ground, what could I do?

local ground = game.Workspace.ground
local car= game.Workspace.car.PrimaryPart

car.Touched:Connect(function(touch)
	if touch then
		script.Parent.fire.Disabled = false
	end
end)

ground.Touched:Connect(function(touch)
	if touch then
		script.Parent.fire.Disabled = true
	end
end)

5 comments

0

I already tried those methods and they did not work for me, thanks.

0

Because other parts of the car are touching it, firing Touched. Add a conditional that checks if touch.Parent ~= car.Parent

0

The thing is that when it enters the vehicle it takes possession of the player and touches the ground I have put a print and the debounce works halfway and the check of if ~ = enters without problems.

1 answer

I got it, thank you very much everyone.

local car = game.Workspace.car.PrimaryPart
local ground = game.Workspace.ground
local fire = game.Workspace.car.fire.fire

car.Touched:Connect(function(touch)
	if touch then
		if touch.Parent ~= ground then
			fire.Disabled = false
			print("false")
		
		end
		
	end
end)
ground.Touched:Connect(function(touch)
	if touch then
		if touch.Parent ~= car.Parent then
			fire.Disabled = true
			print("true")
		end
	end
end)

2 comments

0

For some strange reason it had worked but stopped working.

0

the script works what does not work for me are the particles I do not know what it will be.

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