I’m relatively new to Overhead Gui so I’ve been looking up the basics via the devforum and some youtube videos. The only problem I have encountered is that a majority of the information on it is mainly in regards to Ranks or Group Overhead Guis. Whereas, for what I am trying to accomplish, is completely different. Basically, I’m in the process of making a shop menu and the overhead guis are going to be titles that people can buy in my game and buy/equip whenever they please. I am just unsure entirely how to accomplish that. If anyone can steer me in the right direction via a forum post, roblox database, a youtube tutorial or any other sort of information, then that would be helpful!
You would need to use DataStoreService so that the game knows the player already bought it before.
Or you can give the player a badge everytime a player buys a title, and then check for that badge when the player joins. Although, that is not really a good idea and you will probably need to learn DataStoreService anyways since they are necessary in pretty much every game
Fairly simple, there are many ways of doing this, one of which could be the following:
Detect when a Player has joined the game and give them a BillboardGUI in their Head:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local Billboard = Instance.new("BillboardGui")
Billboard.Parent = char.Head
end)
end)
Size and Offset the billboard UI:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local Billboard = Instance.new("BillboardGui")
Billboard.Parent = char.Head
Billboard.Size = UDim2.fromScale(5,1) -- Step 2
Billboard.StudsOffset = Vector3.new(0,3,0)
end)
end)
Add a text label and size it:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local Billboard = Instance.new("BillboardGui")
Billboard.Parent = char.Head
Billboard.Size = UDim2.fromScale(5,1)
Billboard.StudsOffset = Vector3.new(0,3,0)
local TextLabel = Instance.new("TextLabel") -- Step 3
TextLabel.Parent = Billboard
TextLabel.Size = UDim2.fromScale(1,1)
end)
end)
Add some property changes to your liking:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local Billboard = Instance.new("BillboardGui")
Billboard.Parent = char.Head
Billboard.Size = UDim2.fromScale(5,1)
Billboard.StudsOffset = Vector3.new(0,3,0)
local TextLabel = Instance.new("TextLabel") -- Step 2
TextLabel.Parent = Billboard
TextLabel.Size = UDim2.fromScale(1,1)
TextLabel.BackgroundTransparency = 1
TextLabel.TextScaled = true
TextLabel.Text = ""
end)
end)
This now inserts an overhead GUI, but now we have to change it. You will need to learn datastore as @MasterMinionnn said, and then incorporate a shop system which is too lengthy for devforum. Once that is all said and done, all you need to do is change the overhead GUI’s text to fit that of the title.
I’m familiar with using DataStoreService mainly because I use it to save the leaderstats but how would I go about saving purchases/equips, etc.? Is that something a bit more complicated to handle?
Oh, okay! Would that be a script inserted in ServerScriptService or a local script in StarterPlayer? And for that script, would you not have to manually create a BillboardGui? That script is essentially doing it for you? Because I was thinking you had to create all the tiles and store them somewhere and access them like that. I do appreciate the through instructions though!
Ah, thank you! That simplifies it immensely, haha. So that, in itself, is essentially a template? Would I have to manually enter in the title names for each billboard gui or manually create a physical copy?
For handling purchases, whenever the player tries to buy a title, it fires a RemoteEvent that checks if the player has enough coins for the title, if so, it deducts the amount of coins the title costs and gives the player the title, and saves the new amount of coins and player’s title purchase to the DataStore (the key should be the UserId by the way). Then when the player joins, the server loads the player’s coins, and it can check the key, and see what titles the player has and give it to them.
For equipping, it should be pretty simple. Whenever a player presses the equip button, you can fire a RemoteEvent to the server. Then, the server checks if the player has bought the title, if so, then you can destroy all titles the player currently has (in case the player already has a title equipped) and then give the player the title they equipped. (By the way, you should put all the titles in the ServerStorage and then make a clone of it to give to the player.)
Ah, okay! Thank you so much. This is really making me understand it a lot more! I’ll definitely go and test some things out to see what works for me. I appreciate the guidance and help so far
This would be in a server script in ServerScriptService since we want others to see the title above their head. You do not need to manually add billboards, all you would be doing is changing the text above their head.
Say you had the previous script, and the player bought a title which is now in their inventory, Here is how you would change the text:
You would first need to add a RemoteEvent to your ReplicatedStorage, call it what you will.
--// LOCAL SCRIPT
local TitleButton = YOUR_BUTTON_PATH_HERE
local RE = game.ReplicatedStorage.RemoteEvent
TitleButton.MouseButton1Down:Connect(function()
RE:FireServer("Noob") -- can be whatever title you want above their head
end)
--//SERVER SCRIPT
local RE = game.ReplicatedStorage.RE
RE.OnServerEvent:Connect(function(Player,String)
local Data = DatastoreKey:GetAsync(Player.UserId.."Titles") or ObtainedTitles
if Data[String] then -- checks to see if they own it (if it is in their datastore table)
Player.Character.Head:FindFirstChild("BillboardGui").TextLabel.Text = String
end
end)
(This is when it is in their inventory and they click it, it will equip it)
This is very similar to what @MasterMinionnn suggested, however in mine, I just change the text rather than cloning new ones. The downside to this is you would have to match colours, which isn’t too hard, ultimately it is up to how you want to do it.
Thank you so much for the in depth information/tutorial that you left! Between what you and @MasterMinionnn thoroughly explained, it made me understand this topic a lot more than I ever thought I would by leaving a forum post. I’m really grateful for both of your help and immensely appreciate everything! I’ll try to tackle this shop/overheard gui over the course of this week
Alright, so I am in the process of setting up my shop and I ended up taking the route of manually making the overhead Guis for each title. Although it is probably the more time consuming route, I think it is something I can grasp and understand more than the templates itself. With that being said, I have two questions.
One: Since I am manually making the titles, I am wondering how the datastore script would change with that. I have one title that I have made currently that is stored in ServerStorage:
So would the original script become something like this instead?:
local Datastore = game:GetService("DataStoreService")
local DatastoreKey = Datastore:GetDataStore("Titles")
local ServerStorage = game:GetService("ServerStorage")
local ObtainedTitles ={"Pro";
}
game.Players.PlayerAdded:Connect(function(plr)
local PlayerTitles = DatastoreKey:GetAsync(plr.UserId.."Titles") or ObtainedTitles
plr.CharacterAdded:Connect(function(char)
end)
end)
Two: I have a remote event set up in the purchase button that fires to a server script that is shown below:
Local Script:
game.ReplicatedStorage.BuyTitle.OnServerEvent:Connect(function(player)
if player.leaderstats.Rebirth.Value>10 then
game.ServerStorage.Titles["Pro"]:Clone().Parent = player.Backpack
end
end)
It works and everything but I am wondering if there is a way to display another button like an equip button in replacement of the buy if they already purchased it? Thanks again!
Edit: Oops the buying doesn’t work. I realized it is not player.Backpack. Would it be player.head or something?
local Datastore = game:GetService("DataStoreService")
local DatastoreKey = Datastore:GetDataStore("Titles")
local ServerStorage = game:GetService("ServerStorage")
local ObtainedTitles ={"Pro"; -- the values in this table are what the player STARTS with, keep this in mind, partially my fault, misleading variable name, should be more like "StarterTitles"
}
game.Players.PlayerAdded:Connect(function(plr)
local PlayerTitles = DatastoreKey:GetAsync(plr.UserId.."Titles") or ObtainedTitles -- notice how there is an "or", this means that if there is no save file for this player, it gives them whatever is in the table listed above.
plr.CharacterAdded:Connect(function(char)
end)
end)
for your second question, remember that all we are doing with the datastore is saving values, if we want to retrieve a value, we have to ask the datastore politely C:
That being said, we are going to save the string first, we do so as follows:
game.ReplicatedStorage.BuyTitle.OnServerEvent:Connect(function(player)
local PlayerStats = DatastoreKey:GetAsync(plr.UserId.."Titles") or ObtainedTitles --This will look at what they have
if player.leaderstats.Rebirth.Value>10 and PlayerStats["Pro"] == nil then -- we check to see if they do not already own the "Pro" title
table.insert(PlayerStats,"Pro") -- Add it to the player stats table
DatastoreKey:SetAsync(plr.UserId.."Titles",PlayerStats) -- Now we solidify that they have that title by saving the table!
end
end)
now, if thats all said and done, and you want to then force equip it on them, then you already know what to do for that!
This is super close! it would be player.Character.Head! and you would insert this right under the SetAsync line!
take in mind, this script will only function for the “Pro” title, if you want to diversify it and need help, feel free to reach out! Hope this helps
EDIT: Not sure how you have your inventory system set up, but we also need to set up that they get the pro title when they rejoin