Whenever I try to access a child of PlayerGui ingame (in studio it works fine), it says that GUINAME is not a valid member of PlayerGui. If I use :WaitForChild, it says 'infinite yield possible'.
This is a SCRIPT located in a part in workspace. All the GUIs are valid members of PlayerGui; the script just doesn't think they are.
SCRIPT:
local part = script.Parent
--VALUES--
local shopDebounce = game:WaitForChild("ReplicatedStorage"):waitForChild("Values"):waitForChild("shopDebounce")
_G.shopBlockHitVal = false
--CAMERA--
local Camera = workspace.CurrentCamera
cameraPart = workspace.cameraPart
part.Touched:connect(function(hit)
if _G.shopBlockHitVal == false then
print("no")
wait(1)
_G.shopBlockHitVal = true
print("works")
local h = hit.parent:FindFirstChild("Humanoid")
if h and shopDebounce.Value == false then
print("workin'")
shopDebounce.Value = true
local tweenPosition = coroutine.wrap(function()
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.PlayerGui.shopScreenGui:WaitForChild("mainFrame"):TweenPosition(UDim2.new(0.5, 0, 0.5, 0), "Out", "Quad", 1) --Error
end)
local blurEffect = coroutine.wrap(function() --blur
print("k")
for i = 0, 20, .25 do
game.Lighting.Blur.Size = i
wait(.1)
end
end)
local cameraChange = coroutine.wrap(function()
repeat wait()
Camera.CFrame = cameraPart.CFrame
Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable and Camera.CFrame == cameraPart.CFrame
end)
local fadeIn = coroutine.wrap(function()
for i = 1, 0, -0.05 do
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local fadeFrame = game.Players:GetPlayerFromCharacter(hit.Parent):WaitForChild("PlayerGui"):WaitForChild("fadeEffect"):WaitForChild("Frame") -- Error
fadeFrame.BackgroundTransparency = i
wait(.02)
end
end)
local fadeOut = coroutine.wrap(function()
for i = 0, 1, 0.05 do
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local fadeFrame = game.Players:GetPlayerFromCharacter(hit.Parent):WaitForChild("PlayerGui"):WaitForChild("fadeEffect"):WaitForChild("Frame") -- Error
fadeFrame.BackgroundTransparency = i
wait(.02)
end
end)
fadeIn()
blurEffect()
wait(.75)
cameraChange()
wait(2)
fadeOut()
wait(.1)
tweenPosition()
end
wait(1)
shopDebounce.Value = false
end
end)
Thanks!

1 comment
Could the error have something to do with not using RemoteEvents?