Computer Turn on Script not working

Script for a computer not working

What I am trying to is: As soon as you turn on the computer, a gui should pop up on the screen and show it loading.

But my if statements aren’t working. I tried modifying my script, twisting the code and scripting it in different ways but it doesn’t work.

So I made a screen, engine and a controller.

The Screen
The screen has a sruface gui a frame, a text label and a script in the text label.

The Controller
I added Proximity Prompt and a script.

The Controller
Mainly has the on and off lights.

Script for the text label on the screen:


local function BeginLoad()
	script.Parent.Parent.Visible = true
	for i = 0, 100, 1 do
		wait(0.1)
		script.Parent.Text = "Starting Up "..i

		if i == 100 then
			wait(2)
			script.Parent.Text = "Loaded Assets!"
			wait(2)
			script.Parent.Parent:Destroy()
		end
	end
	
end

if game.Workspace.Engine.On.PointLight.Enabled == true then
	BeginLoad()
else
	script.Parent.Parent.Visible = false
end


The script for the button:
script.Parent.Triggered:Connect(function()

game.Workspace.Engine.On.PointLight.Enabled = true
game.Workspace.Engine.Off.PointLight.Enabled = false

script.Parent.Parent.Status.Value = true

end)

Are these both server scripts or is one a local script and the other a server script?

image

It will turn on the point light when the proximity prompt is triggered.

My bad, saw that one is off and the other is on

You’re going to have to use a remote event then. Make the Proximity prompt script a local script and fire a server event from it, and then in the other script use the OnServerEvent to run a function that contains the if statement.

I’ll try but I don’t think remote events are supposed to be used for these.

Probably not but essentially that if statement is only checked once and that’s it.

Another way would be to have it all in one script and run the function when the proximity prompt is triggered or simply run that if statement in a while loop.