Help with gui appearing when it shouldnt

Hello, this script should make it so a gui appears when i touch a block, it used to work but after some editing without testing it stopped, Now it appears when i spawn in. I checked output and no errors showed. Please help me fix it.

local close = game.Workspace.closePart
local frame = script.Parent
local closeButton = frame.closeButton
local buy_1 = frame.Buy1
local buy_2 = frame.Buy2
local buy_3 = frame.Buy3

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild('BuyTool')

frame.Visible = false

local function shopMenu(otherPart)
	local player = game.Players:FindFirstChild(
	if player then
		player.PlayerGui.ScreenGui.Shop.Visible = true
		player.Character.Humanoid.WalkSpeed = 0

local function closeMenu()
	local player = game.Players.LocalPlayer
	player.PlayerGui.ScreenGui.Shop.Visible = false
	player.Character.HumanoidRootPart.CFrame =,close.Position.Y + 3,close.Position.Z)
	player.Character.Humanoid.WalkSpeed = 16

local function buyTool1()

1 Like

You are doing Shop.Visible = false and frame.Visible = false.

Maybe this is the problem.

1 Like

after trouble shooting i found that this is the error, i dont know how to fix it, can you help?

local remoteEvent = ReplicatedStorage:WaitForChild('BuyTool') ,

the lua cut off some of my message, i tried to send this:
local ReplicatedStorage = game:GetService(‘ReplicatedStorage’)
local remoteEvent = ReplicatedStorage:WaitForChild(‘BuyTool’)

Is the RemoteEvent in ReplicatedStorage called “BuyTool”? That may be the error, if it says Infinite Yield possible on ReplicatedStorage.BuyTool

1 Like

You’re a life saver, i would have never noticed this, thank you.

1 Like

You’re welcome! :grinning: Have fun!