I want to write a script so that after touching an object (in my case, a bed), the screen turns completely black. Here is the script itself:
script.Parent.Touched:Connect(function(part) --i use part instead of hit
if part.Parent:FindFirstChild("Humanoid") then
game:GetService("StarterGui").AfterDays.ScreenGui.FrameNumber1.Visible = true
end
end)
I completely took and redid the script from the obbi block (which kills when touched) and made it for myself, first I tested this script with a simple command in which I just changed the game time:
script.Parent.Touched:Connect(function(part) --i use part instead of hit
if part.Parent:FindFirstChild("Humanoid") then
game:GetService("Lighting").TimeOfDay = 0
end
end)
I tested the script and it worked, then transferred it to the bed model and when touched, everything worked the same way. Then I created a Gui that makes the player's screen completely black and then wrote a script so that instead of changing the time, this Gui is activated:
script.Parent.Touched:Connect(function(part) --i use part instead of hit
if part.Parent:FindFirstChild("Humanoid") then
game:GetService("StarterGui").AfterDays.ScreenGui.FrameNumber1.Visible = true
end
end)
But the script doesn't work for some reason, I'm not very good at scripting and I don't understand why it doesn't work.
(Translated from Russian)
The way to the bed: game.workspace.ModelBed
Path to the script: game.workspace.ModelBed.PartWithScriptNumber1.script
The Gui path is: game:GetService("StarterGui").AfterDays.ScreenGui.FrameNumber1