If a part is clicked using a ClickDetector, a Gui (in the StarterGui folder) should show up. This works in Studio but not when I test the game with FilteringEnabled. How can I fix that? I use this script for interacting with things (i.e. turning on the tv, light switches, etc.) and it works fine for things like that. I figured it would work for this as well, but it doesn't.
local ClickerModule = require(343254562)
local clickEvent = ClickerModule.RemoteEvent
local interactiveParts = {}
local activationDistance = 14
local guiOpen = false
local changingState = false
for i, v in pairs(script.Parent:GetChildren()) do
if v.Name == "Interactive" then
table.insert(interactiveParts, v)
end
end
local function distanceToCharacter(player, part)
local character = player.Character
if character then
local torso = character:FindFirstChild("Torso")
if torso then
return((torso.Position - part.Position).magnitude)
end
end
return math.huge
end
clickEvent.OnServerEvent:connect(function(player, part)
local isPart = false
for i = 1, #interactiveParts do
if part == interactiveParts[i] then
isPart = true
end
end
if isPart and player.Character and distanceToCharacter(player, part) <= activationDistance then
if guiOpen == true and changingState == false then
changingState = true
player.PlayerGui.Dialog.Frame1.Visible = true -- do this on click
changingState = false
guiOpen = false
elseif changingState == false then
changingState = true
player.PlayerGui.Dialog.Frame1.Visible = true -- reopen if clicked again
changingState = false
guiOpen = true
end
end
end)

1 comment
From what I can see from your script, it should be working. Can you check the output from your server with F.E. using F9?