Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ScreenGui is not a valid member of PlayerGui?

This script works in regular studio testing mode, but not ingame. Any help? I'm getting the error ScreenGui is not a valid member of PlayerGui on line 6.

script.Parent.Hitbox.Touched:connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if hit.Parent:FindFirstChildWhichIsA("Humanoid") ~= nil then
		if player.CarryingB.Value == false then
			player.CarryingB.Value = true
			player.PlayerGui.ScreenGui.Battery:TweenPosition(UDim2.new(0.85, 0, 0, 0), "Out", "Sine", 1)
			script.Parent:Destroy()
		end
	end
end)

10 comments

0

if it is a ServerScript, change it to a LocalScript.

0

still not working

0

Try changing the name "ScreenGui" to something else.

0

try for the variable player.. game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

0

@TinyScripter that's absolutely incorrect. LocalScripts CANNOT function in the workspace.

0

You need to use player.PlayerGui:WaitForChild("ScreenGui") instead of player.PlayerGui.ScreenGui. That will help. If it doesn't, use FindFirstChild.

0

it's still not working... are you supposed to do player.PlayerGui:FindFirstChild("ScreenGui").Battery? i'm getting the error attempt to index a nil value

0

also, when i use waitforchild, i'm getting an infinite yield possible warning

0

Try player.StarterGui.ScreenGui.Battery?

0

please help im having same proplem im making a dj stand so when the dj clicks on the brick it should show a gui but it works perfectly in studio but not in game and i keep getting this error Screengui is not a valid member of playergui adn underneath it says workspace.DjstandBrick.script', Line 3 Stack end Please if anybody know whats wrong please reply

2 answers

This discussion is preserved as it was. New answers, comments, and votes are closed.