Gui menu labelling

Hello everyone! I just finished watching alvinbloxes tutorial on how to make a tool gui and everything went well and he shows how to make a a title for the gun and what not but I was wondering how do you make it to show the price of the weapon with the name of it. Also I wanted to know how I can make my guns order from lowest price to the highest price like how most games do. Thanks for any help!

1 Like

For the Weapon label you can you use a StringValue to check the TextLabel and display whatever you input

2 Likes

I did that but kept getting an error saying attempt to index nil with “Value”

Make sure the object is a StringValue and that you’re not referencing an uncreated object/nothing.

I did and I had a textlabel for where it will display the cost and I had the string value but still got the error

I would make sure in your code that you are referencing the correct value. If you’re still getting this please show me your code so I can have more to reference off of.

Well I still got the error here is a picture of my code with the stringvalue and the value of the string value

Try removing the .Name after tool.

objectPrice.Text = tool.Price.Value

thanks man, works perfectly great!

Glad to hear! Please mark it as the solution.

Sorry was doing more testing and found out that the prices go to the wrong guns

Some values go to the right guns while other go to the wrong guns

I dont really know how your script works but make sure all the prices in the gun are correct and also make sure you have nothing changing prices after they are set.

There is nothing that is changing the price because the price I added just for showing the price and also they are all correct

Only problem that I can think of is that the weapons are not getting defined correctly causing the prices to go to random guns

If you could show me your entire script it would help. I can think of a couple of reasons it may be occurring.

  • Something is changing the price label
  • The prices values are incorrect
  • They are getting defined incorrectly/referenced incorrectly

I will send it to you in about 5 minutes I am going to go eat dinner real quick

Thats fine, I will look over what you have sent already for anything that could be occurring.

ok so I finished and here is the script

local folder = game.ReplicatedStorage:WaitForChild("Tools")

local frame = script.Parent:WaitForChild("ScrollingFrame")

local template = frame.Template

local shopButton = script.Parent:WaitForChild("ShopButton")

local objectPrice = template:WaitForChild("ObjectPrice")


for _, tool in pairs(folder:GetChildren()) do
	local newTemplate = template:Clone()
	newTemplate.Name = tool.Name
	newTemplate.ObjectName.Text = tool.Name
	newTemplate.Visible = true
	newTemplate.Parent = frame
	
	local objectPrice = template:WaitForChild("ObjectPrice")
	objectPrice.Text = tool.Price.Value 
	
	local object = tool:Clone()
	object.Parent = newTemplate.ViewportFrame
	
	local camera = Instance.new("Camera")
	camera.CFrame = CFrame.new(object.Handle.Position + (object.Handle.CFrame.lookVector*5)+ Vector3.new(2,2,2),object.Handle.Position)
	camera.Parent = newTemplate.ViewportFrame
	
	newTemplate.ViewportFrame.CurrentCamera = camera
	
	
	newTemplate.MouseButton1Click:Connect(function()
		local result = game.ReplicatedStorage.BuyItem:InvokeServer(tool.Name)
		if result == true then
			
			newTemplate.BackgroundColor3 = Color3.new(0.00392157, 1, 0.0352941)
			
		else
			
			newTemplate.BackgroundColor3 = Color3.new(0.92549, 0, 0)
		end
		
		wait(1)
		
		newTemplate.BackgroundColor3 = Color3.new(1, 1, 1)
	end)
end

shopButton.MouseButton1Click:Connect(function()
	frame.Visible = not frame.Visible
end)

Are the same prices getting messed up or is it random?