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

I need help with my player script and i dont understand how i will make it so can someone help?

Hello,

I trying to make a script so whenever a player joins the game it will shows his name on a GUI and tell if he owns a t-shirt or not but i dot understand how to do it,

Game.Players.PlayerAdded:connect(function(plr)
     script.Parent.Name.Text = plr.Name
       if game:GetService("MarketPlaceService"):PlayerOwnsAsset(plr, 123123) then
      script.Parent.Text.Text = "He Owns The T-shirt"
      end
end)

2 answers

I've also done this. So first you need to put a BillboardGUI in ServerStorage. Then put a TextLabel into that BillboardGUI with the text you want to be displayed(you don't need to define it in the script, but it could be useful). You will also need to make a script so the text appears above the player's head. Your script should be placed in ServerScriptService and look like this:

local gui = game:GetService("ServerStorage"):WaitForChild("Label") -- Put the name of the TextLabel instead of Label

game.Players.PlayerAdded:connect(function(plr)
	if game:GetService("MarketPlaceService"):PlayerOwnsAsset(plr, 123123) then
		local clonedGui = gui:Clone()
		clonedGui.Parent = game.Workspace[plr.Name].Head
	end
end)

Also, change the BillboardGUI's StudsOffset property to about 0, 3, 0 so it appears above your head and not in it. If you want to have multiple texts shown above your player then just add another TextLabel, but change it's StudsOffset to about 0, 6, 0 so it's not in player's head and not in the other text.

I hope I helped you, and if your problem is solved don't forget to write '[SOLVED]' after your title so it's visible that it's solved.

You seem to have the majority correct. Here look at what my re-write is:

Game.Players.PlayerAdded:connect(function(plr)

     local name = plr.Name

       if game:GetService("MarketPlaceService"):PlayerOwnsAsset(plr, 123123) then

      script.Parent.Text =  name + " He Owns The T-shirt"

      end

end)

this should work!

1 comment

0

That would error.

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