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

How would i make a script so when i sit in a seat a monitor screen changes to neon material?

So i made a monitor and i have a chair but i want the monitor screen to light up so change the material to neon. So it shows like you would be using the computer. I really have not experimented changing/manipulating parts with scripts before.

3 answers

✓ Accepted answer
local Seat = script.Parent -- The seat
local Monitor = PathToMonitor -- Change to where your monitor is

Seat:GetPropertyChangedSignal("Occupant"):Connect(function() -- Run the below code when the Occupant changes
	if Seat.Occupant then -- Checks if someone is sitting in the Seat
		Monitor.Material = Enum.Material.Neon -- If someone is sitting in the seat
	else
		Monitor.Material = Enum.Material.Plastic -- If someone is not sitting in the seat
	end
end)

Don't forget to mark my answer as the solution and upvote it if it solved your problem :)

2 comments

0

Chooses the answer that was newer than mine

0

Your code doesn't work tho, OnChanged isn't an event and you don't even know how to check if the Occupant is a Humanoid

Assuming it doesn't matter who is in the seat, this could work: (put script in seat)

local monitor = ??? --Make this the location of the monitor
script.Parent.Occupant.OnChanged:connect(function()
	if script.Parent.Occupant == humanoid then 
		monitor.Material = Enum.Material.Neon
	else
		monitor.Material = Enum.Material.Plastic --Change this to the default material
	end
end

1 comment

0

You can't do that, it better to use monitor = game.Parent.Monitor

Hello Tnipo, I have found a solution to your problem.

place the script inside the seat.

Good Luck!

--script is inside seat

--get reference to seat
local Seat = script.Parent

-- get reference to "Occupant" property of seat
local Occupant = Seat.Occupant

--get reference to screen (your path may differ)
local Screen = script.Parent.Parent.Parent.Monitor.Screen

--create material variables
local Neon = Enum.Material.Neon
local SmoothPlastic = Enum.Material.SmoothPlastic

--create function to handle the event
local function toNeon()
	if Seat.Occupant then
		Screen.Material = Neon
	else
	Screen.Material =SmoothPlastic
	end
end

--fires event
Seat:GetPropertyChangedSignal("Occupant"):Connect(toNeon)
-- the above line detects when the "Occupant" property of the seat is changed, and then executes the function toNeon()

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