I’d like to have a local script to access a ScreenGui.
The issue is that it just can’t.
I have tried WaitForChild() and just the normal
PlayerGui.ScreenGui
and also FindFirstChild()
Here is my code.
local runService = game:GetService("RunService")
local collectionService = game:GetService("CollectionService")
local waterGui = game:GetService("Players").LocalPlayer.PlayerGui:WaitForChild("ScreenGui").Water
local camera = workspace.CurrentCamera
local camPosPart = Instance.new("Part")
camPosPart.Name = "CameraPos"
camPosPart.Size = Vector3.new(0.001,0.001,0.001)
function touchingWater()
local touching = workspace:GetPartsInPart(camPosPart)
local notTouchingWater = 0
for i, part in pairs (touching) do
if collectionService:HasTag(part, "Water") then
waterGui.Visible = true
else
notTouchingWater += 1
end
end
if notTouchingWater == #touching then
waterGui.Visible = false
end
end
runService.RenderStepped:Connect()