Price showing "Free" instead of "100"

  1. What do you want to achieve?
    Make the side bar display “100 Souls” instead of “Free”

  2. What is the issue?
    Even though the price is set to 100 it still displays it as free no matter what.

  3. What solutions have you tried so far?
    None

Script that creates the shop entires:

local weapons = game:GetService("ServerStorage").Weapons
local player = script.Parent.Parent.Parent.Parent.Parent
local shop = script.Parent.Parent
local contentFrame = script.Parent
local information = script.Parent.Parent.Details

for i, weapon in pairs(weapons:GetChildren()) do
	
	if player:WaitForChild("leaderstats").Souls.Value >= weapon.RequiredSouls.Value then
		local template = script.Parent.Template:Clone()
		template.Name = weapon.Name
		template.WeaponName.Text = weapon.Name
		template.Parent = script.Parent

		local weaponRender = weapon.ViewportModel:Clone()
		weaponRender.Parent = template.Render
		
	else
		
		local template = script.Parent.Template:Clone()
		template.Name = weapon.Name
		template.WeaponName.Text = "???"
		template.Parent = script.Parent

		local weaponRender = weapon.ViewportModel:Clone()
		weaponRender.Parent = template.Render
		
		weaponRender.Parent.Ambient = Color3.fromRGB(0, 0, 0)
		weaponRender.Parent.LightColor = Color3.fromRGB(0, 0, 0)
		
	end
end

Script inside every shop entry

local player = script.Parent.Parent.Parent.Parent.Parent.Parent
local template = script.Parent
local details = script.Parent.Parent.Parent.Details
local weapon = game:GetService("ServerStorage").Weapons[template.Name]

local weaponTool

template.Select.MouseButton1Click:Connect(function()
	for i, tool in pairs(weapon.Tool:GetChildren()) do
		weaponTool = tool
	end
	if details.Render:FindFirstChild("ViewportModel") then
		details.Render.ViewportModel:Destroy()
	end
	
	if player.leaderstats.Souls.Value >= weapon.RequiredSouls.Value then
		script.Parent.Locked.Value = false
		details.Title.Text = template.Name
		details.Render.Ambient = Color3.fromRGB(200, 200, 200)
		details.Render.LightColor = Color3.fromRGB(140, 140, 140)
		script.Parent.Render:WaitForChild("ViewportModel"):Clone().Parent = details.Render
	else
		script.Parent.Locked.Value = true
		details.Title.Text = "???"
		details.Render.Ambient = Color3.fromRGB(0, 0, 0)
		details.Render.LightColor = Color3.fromRGB(0, 0, 0)
		script.Parent.Render:WaitForChild("ViewportModel"):Clone().Parent = details.Render
	end
	
	details.Damage.Text = "+" .. weaponTool.Damage.Value .. " Damage"
	details.Delay.Text = weaponTool.UsageDelay.Value .. " Second Delay"
	if not weapon.RequiredSouls.Value == 0 then
		print("not free")
		details.UnlocksAt.Text = weapon.RequiredSouls.Value .. " Souls"
	else
		print(weapon)
		print("free")
		details.UnlocksAt.Text = "Free"
	end
	
end)

1 Like

You used not x == y instead of x ~= y or not (x == y).
Due to unary not having higher precedence than the binary ==. It evaluates to boolean, and boolean cannot equal to 0 because == will always evaluate to false on operands that are different types so only the else --[[...]] end branch will always be executed.

I’d change from not weapon.RequiredSouls.Value == 0 to weapon.RequiredSouls.Value ~= 0.

1 Like

Now it shows the amount of souls but the one that is 0 souls says “0 souls” instead of free like it should.

Forgot to remove the ‘not’, works now!