Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

ScreenGui is not a valid member of PlayerGui?

Asked by 6 years ago

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)

0
if it is a ServerScript, change it to a LocalScript. TinyScripter 70 — 6y
0
still not working Reziztor 4 — 6y
0
Try changing the name "ScreenGui" to something else. thesit123 509 — 6y
0
try for the variable player.. game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) greatneil80 2647 — 6y
View all comments (6 more)
0
@TinyScripter that's absolutely incorrect. LocalScripts CANNOT function in the workspace. PyccknnXakep 1225 — 6y
0
You need to use player.PlayerGui:WaitForChild("ScreenGui") instead of player.PlayerGui.ScreenGui. That will help. If it doesn't, use FindFirstChild. PyccknnXakep 1225 — 6y
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 Reziztor 4 — 6y
0
also, when i use waitforchild, i'm getting an infinite yield possible warning Reziztor 4 — 6y
0
Try player.StarterGui.ScreenGui.Battery? T0XN 276 — 6y
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 mcdog73 0 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

I have the same problem.

Ad
Log in to vote
0
Answered by 4 years ago

Try doing

script.Parent.Parent = nil

Answer this question