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

Attempting to access a PlayerGui, but it errors?

Hey all! So, my script works fine, except for line 20, when I attempt to access "Victim"'s PlayerGui. "Victim" is the Player of the character I click with my mouse. It keeps saying "PlayerGui" isn't a valid member of "Player", and whenever I put WaitForChild, or repeat wait(), it still says the same error. Any tips? Thanks!

repeat wait() until script.Parent.Parent.Name~="Backpack"
wait()

tool = script.Parent
Citation = game.Lighting.CitationsDB
Player = game.Players.LocalPlayer

tool.Equipped:connect(function(mouse)
	if not Player:findFirstChild("PlayerGui") then return end
	if Player.PlayerGui:findFirstChild("CitationsDB") then return end
	mouse.Button1Down:connect(function()
		if mouse.Target then
			if game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then
				local Victim = game.Players:GetPlayerFromCharacter(mouse.Target.Parent)
				Citation:clone().Parent = Player.PlayerGui
				local GUI = Player.PlayerGui.CitationsDB
				GUI.CitationsDB:TweenPosition(UDim2.new(0.5,-160,0.5,-100),'Out','Quad',0.35)
				GUI.Citee.Value = Victim.Name
				GUI.CitationsDB.Citation.Username.Text = "Username: "..Victim.Name
				Victim.PlayerGui.ScreenGui:Destroy()
			end
		end
	end)
end)

3 comments

0

PlayerGui isn't visible to the server or it hasn't loaded.

0

I think the error started at line 14.

0

It has loaded, because the person I'm trying to access their GUI, they have all of their GUIs set. @TheContinetofEurope How could I fix that?

1 answer

Just use game.StarterGui:SetCoreGuiEnabled and disable the cores using this code.

game.StarterGui:SetCoreGuiEnabled("Chat","PlayerList",Health")
--It might not work with the multi-syntax.
-- Just do it one by one.

3 comments

1

How does this relate to Accessing the PlayerGui?

0

Yeah... Nice try, though..

0

Ah, you meant the actual StarterGui?

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