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

How do I make it so it addresses it to the head of the player?

The following script is me attempting to make it so once a player joins or resets they have the VIP GUI but only if they own the gamepass thing. The only issue is the output said: "Head is not a valid member of Player". I believe it's because it addresses the player in the script to the player categories and not the Workspace because the workspace holds the player's head and body parts. So, how do I make it so where it says ' newPlayer.Head.NameTag.VIP.Visible = true ' be addressing to the new player in the workspace and not the place where it is getting feedback from currently? Here is the script that I'm using. The GUI is inside ServerScriptService.

game.Players.PlayerAdded:connect(onPlayerRespawned)
function onPlayerRespawned(newPlayer)
	wait(1)
		if game.MarketplaceService:PlayerOwnsAsset(newPlayer, 4692779139) then
newPlayer.Head.NameTag.VIP.Visible = true
end
end

function onPlayerEntered(newPlayer)
	newPlayer.Changed:connect(function (property)
		if (property == "Character") then
			onPlayerRespawned(newPlayer)
		end
	end)
end

game.Players.PlayerAdded:connect(onPlayerEntered)

1 answer

The issue here is that you are looking for the player's head inside of the actual Player instance instead of the player's Character. Here's what you can do to actually access the player's head:

--When the player is added
game.Players.PlayerAdded:Connect(function(player)
	--When the character is added
	player.CharacterAdded:Connect(function(character)
		character.Head.NameTag.VIP.Visible = true
	end)
end)

If you're trying to access the player's Character outside of detecting every time the character is added, you can use the Character property of Player (player.Character).

Hope this helps.

1 comment

0

Where do I insert that?

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