I am making it so when the player touches a part it opens a shop Gui, but every time the player walks it flickers to enabled to disabled. I know why this happens, but I do not know how to fix it.
Here's the script:
local shopGui = script.Parent
local shopGuiTrigger = game.Workspace.ShopGuiTrigger
shopGuiTrigger.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
local localPlayer = game.Players.LocalPlayer
if hum and localPlayer then
shopGui.Enabled = true
end
end)
shopGuiTrigger.TouchEnded:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
local localPlayer = game.Players.LocalPlayer
if hum and localPlayer then
shopGui.Enabled = false
end
end)