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

Can somebody help me properly call PlayerGui?

local Players = game:GetService("Players")


local function onPartTouch(identifier)
	local partParent = identifier.Parent
	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	local player = Players:GetPlayerFromCharacter(partParent)
	local getplayerz = game.Players:GetChildren("Player")
	if humanoid and player.Name == "SamZeKat" then
		
		
		
		
		getplayerz.PlayerGui.yes.Enabled = true
		
		
	end
end

script.Parent.Touched:Connect(onPartTouch)

Coming with the error: Attempted to index with nil yes

1 answer

✓ Accepted answer

Change

getplayerz.PlayerGui.yes.Enabled = true

to

player.PlayerGui.yes.Enabled = true

Since getplayerz is a table containing all the Players

Also make sure identifier.Parent is a Character first, before running this :

local player = Players:GetPlayerFromCharacter(partParent)

your accessory's handle could be hitting the part and Identifier.Parent might be an accessory

1 comment

0

It worked! TYSM

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