I tried to create a script that makes a frame visible on part touch. For some reason, it only works once.
How can I solve this?
local Part = script.Parent
local Players = game:GetService("Players")
Part.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
local Char = Hit.Parent
local Player = Players:GetPlayerFromCharacter(Char)
if Player.PlayerGui.ShopGui.Frame.Visible == false and Player.PlayerGui.ShopGui.Close.Visible == false then
Player.PlayerGui.ShopGui.Frame.Visible = true
Player.PlayerGui.ShopGui.Close.Visible = true
elseif Player.PlayerGui.ShopGui.Frame.Visible == true and Player.PlayerGui.ShopGui.Close.Visible == true then
print("GuiAlreadyVisible")
end
end
end)