Script not changing BoolValue

I am trying to make a BoolValue change when a player sits on a seat but nothings happening and
the Output tab isn’t showing any errors so I think I might be missing something

Script:

	script.Parent.Touched:connect(function(hit)	
		script.Parent.ChildAdded:connect(function(child)
			if child.Name=="SeatWeld" then
				script.Parent.DustOff = true
			end
		end)
	end)
end

NOTE: I have fixed the .Value in line 4 but the script still wont change the value

Explorer tab: Capture130

Change script.Parent.DustOff to script.Parent.DustOff.Value. You are indexing the instance itself, not the value property.

I just realized that. I fixed it too but the script is still not changing the value of the BoolValue

script.Parent.DustOff.Value = true

you forgot the .Value part i think

Try printing to debug what has gone wrong and check the output if there are errors. It can be because the SeatWeld isn’t added.

This function should work better:

function checkOccupant()
	if seat.Occupant ~= nil then --checks if there is someone in the seat
		local findPlayer = game.Players:FindFirstChild(seat.Occupant.Parent.Name) --finds player from the character's Name
		if findPlayer then
			print("player has sat down")
            script.Parent.DustOff.Value = true
		end
      else
         script.Parent.DustOff.Value = false
      end
end

seat.Changed:Connect(function()
	checkOccupant() --fires whenever someone sits down or leaves the seat
end)

I fixed that but the value is still not changing

I will try that give me a second

I tried that however it didn’t work

Any errors in the output, and this is in a server script? Also you are trying to detect when a player sits down on the seat right?

No errors in output, not in SSS and yes I am trying to detect when a player sits down in order to change a BoolValue

I will try putting it in SSS and see if that works

Just don’t forget to redefine the seat variable.

I already did that

SSS doesn’t work too

Very strange, that script worked for me. Try adding prints, and are you sure that the variable “seat” is the Vehicle Seat

It needs to be a server script.

Here is the code I used

local seat = script.Parent

function checkOccupant()
	script("Check_1")
	if seat.Occupant ~= nil then --checks if there is someone in the seat
		local findPlayer = game.Players:FindFirstChild(seat.Occupant.Parent.Name) --finds player from the character's Name
		if findPlayer then
			print("player has sat down")
			script.Parent.DustOff.Value = true
		end
	else
		script.Parent.DustOff.Value = false
	end
end

seat.Changed:Connect(function()
	checkOccupant() --fires whenever someone sits down or leaves the seat
end)

Check_1 didn’t print

First of all, you’re using a local script, local scripts don’t run in Workspace unless inside the own player’s character, that’s a vehicle seat;

Yes is this in a normal script or in a local script??

Oops, let me see if a normal script works

Its on a local, you can see on the screenshot on the main post;