UI error, "not valid member of StarterGui"

yea, i was telling him that, but i think he was just being told to do that and that he cant say otherwise

So after looking at this code, I decided to revamp the whole thing for ya!
I’ll go step-by-step on how to set this up

1: Create a folder in replicated storage called “Sounds” and in that folder create another folder called “JumpscareSounds” (Put your desired jumpscare sounds In JumpscareSounds)

2: Create a folder in replicated storage called “Events” and in that folder create another folder called “JumpscareEvents”

3: Create a folder in replicated storage called “ScreenGuis” and parent your desired ScreenGui into it. Make sure IgnoreGuilnset is turned on, Enabled is turned off, and the ScreenGui’s name is Jumpscare1.

4: Create a remote event in replicated storage called “JumpscareEvent1” and parent it into “JumpscareEvents”

5: In workspace, (not assuming you dont have a part the player will step on) make a part, anchor it, and put a server script inside of it. In that script copy and paste this code into it

local debounce = false
local DebounceLength = 4 -- How long it takes until the part can detect when a player dies again (try to match this up with the respawn time).
-- (4 goes with the default respawn time btw)

local event = game.ReplicatedStorage.Events.JumpscareEvents.JumpscareEvent1
local players = game:GetService("Players")

players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)


		local function Touched()
			print("Function Activated")
			event:FireClient(Player)			
			end
		

script.Parent.Touched:Connect(function()
			Character.Humanoid.HealthChanged:Connect(function(health)
				if health <= 0 and not debounce then
					debounce = true
				Touched()
				task.wait(DebounceLength)
				print("Debounce ended")
				debounce = false
						end
					end)
				end)
			end)
		end)

5: Create a client script in StarterGui, name this whatever you want. In this script copy and paste this code into it.

local Player = game.Players.LocalPlayer
local Character = Player.Character

local event = game.ReplicatedStorage.Events.JumpscareEvents.JumpscareEvent1
local sound = game.ReplicatedStorage.Sounds.JumpscareSounds.JumpscareSoundHere


event.OnClientEvent:Connect(function()

	if Player.PlayerGui:FindFirstChild("Jumpscare1") then
	else
		local Jumpscare = game.ReplicatedStorage.ScreenGuis.Jumpscare1
		local JumpscareClone = Jumpscare:Clone()

		JumpscareClone.Parent = Player.PlayerGui

		JumpscareClone.Enabled = true
		sound:Play()

		wait(2)

		JumpscareClone.Enabled = false

		Player.PlayerGui:FindFirstChild("Jumpscare1"):Destroy()
		print("Destroyed")
	end
end)

If u encounter any issues with this please reply and I’ll try to help you out. (no credit is needed btw)