I made this script that makes a gui visible if you own the given id on touched and then the gui is no longer visible when TouchEnded, how can I make this compatible with Filtering Enabled?
local id = 490992945
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local frame = player.PlayerGui.ScreenGui:WaitForChild("Frame")
local sf = player.PlayerGui.ScreenGui:WaitForChild("ScrollingFrame")
if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,id) then
if frame.Visible == false and sf.Visible == false then
frame.Visible = true
sf.Visible = true
end
else
game:GetService("MarketplaceService"):PromptPurchase(player,id)
end
end
end)
script.Parent.TouchEnded:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local frame = player.PlayerGui.ScreenGui:WaitForChild("Frame")
local sf = player.PlayerGui.ScreenGui:WaitForChild("ScrollingFrame")
if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,id) then
if frame.Visible == true and sf.Visible == true then
frame.Visible = false
sf.Visible = false
end
end
end
end)
