On Touched Event Problem!

Problem:

I made a script to make a frame invisible when a player touches it. But It doesn’t seem to be working.

script:

local player = game.Players.LocalPlayer
local part = script.Parent
local gui = player:WaitForChild(“PlayerGui”):WaitForChild(“DefeatBanditsGui”)
local frame = gui:WaitForChild(“FrameFirst”)
part.Touched:Connect(function()

if player:WaitForChild("Quest1").Value == 4 then
	
	frame.Visible = false
end

end)

Assuming this is from a local script, they don’t run in workspace.

-- Server script

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild('Humanoid') ~= nil then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Player found from touch
        local gui = player:WaitForChild('PlayerGui'):WaitForChild('DefeatBanditsGui')
        local frame = gui:WaitForChild('FrameFirst')
        if player:WaitForChild("Quest1").Value == 4 then
        	frame.Visible = false
        end
    end
end)

I tried this previously but it did not work because I made the Gui visible in the first place by using a local script

Transfer the script I sent you into a server script and parent it to the part, it should work.

oh ok Ill try that right away and tell you if it works

It did not work but thanks for the help!

Can I see your explorer, specifically the part where you put this script, as well as your StarterGui?

Nvm fixed the problem it was a problem on my end.