Need help with showing the amount of money obtained from selling

I need help with showing the amount of money obtained from selling, the sell system requires a dialogue ( which i’ve already made ), i want to change the $ amount to the amount obtained from selling the currency


Here’s the script :
(Dialogue)

local pp = game:GetService("ProximityPromptService")
local mf = script.Parent.Main
local cb = mf.Continue
local dialog = mf.Dialogue
local name = mf.NPC
local Npcimage = mf.NPCimage
local c1 = mf.Parent.Choose1
local c2 = mf.Parent.Choose2
local money = 0
local sell = game:GetService("ReplicatedStorage"):WaitForChild("Sell")

-- Animation settings
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(0.8, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local ti2 = TweenInfo.new(1.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local ti3 = TweenInfo.new(2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)

-- GUI settings
c1.Position = UDim2.new(0.613, 0, 0.771, 0)
c2.Position = UDim2.new(0.613, 0, 0.879, 0)
c1.Transparency = 1
c2.Transparency = 1
c1.Visible = false
c2.Visible = false
mf.Visible = false
mf.Transparency = 1
cb.Transparency = 1
dialog.Transparency = 1
name.Transparency = 1
Npcimage.Transparency = 1

-- Debounce
local pt = false
local bc1 = false
local bc2 = false
local bc3 = false

local function typewrite(object, text, length)
	for i = 1, #text, 1 do
		object.Text = string.sub(text, 1, i)
		wait(length)
	end
end

pp.PromptTriggered:Connect(function(prompt)
	if prompt.Name == "Dialog" then
		if pt == false then
			pt = true
			if prompt.Parent.Name == "Sell man" then
				name.Text = "Sell Man"
				dialog.Text = ""
			end
			print("dialogopened")
			if mf.Visible == false then
				mf.Visible = true
			end
			ts:Create(mf, ti, { Transparency = 0 }):Play()
			ts:Create(cb, ti, { ImageTransparency = 0 }):Play()
			ts:Create(dialog, ti, { TextTransparency = 0 }):Play()
			ts:Create(name, ti, { TextTransparency = 0 }):Play()
			ts:Create(Npcimage, ti, { Transparency = 0 }):Play()
			ts:Create(Npcimage, ti, { ImageTransparency = 0 }):Play()
			typewrite(dialog, "You want to sell?", 0.02)
			cb.MouseButton1Click:Connect(function()
				if bc1 == false then
					print("choosedialog")
					bc1 = true
					c1.Visible = true
					c2.Visible = true
					wait(0.1)
					ts:Create(c1, ti, { Position = UDim2.new(0.777, 0, 0.771, 0) }):Play()
					ts:Create(c1, ti2, { BackgroundTransparency = 0.2 }):Play()
					ts:Create(c1, ti2, { TextTransparency = 0 }):Play()
					ts:Create(c2, ti, { Position = UDim2.new(0.777, 0, 0.879, 0) }):Play()
					ts:Create(c2, ti2, { BackgroundTransparency = 0.2 }):Play()
					ts:Create(c2, ti2, { TextTransparency = 0 }):Play()
					c1.MouseButton1Click:Connect(function()
						if bc2 == false then
							print("sell")
							sell:FireServer()
							bc2 = true
							typewrite(dialog, "It'll be "..money.."$", 0.05)
							cb.MouseButton1Click:Connect(function()
								if bc3 == false then
									ts:Create(c1, ti3, { Transparency = 1 }):Play()
									ts:Create(c2, ti3, { Transparency = 1 }):Play()
									ts:Create(mf, ti3, { Transparency = 1 }):Play()
									ts:Create(cb, ti3, { Transparency = 1 }):Play()
									ts:Create(dialog, ti3, { TextTransparency = 1 }):Play()
									ts:Create(name, ti3, { TextTransparency = 1 }):Play()
									ts:Create(Npcimage, ti3, { ImageTransparency = 1 }):Play()
									ts:Create(Npcimage, ti3, { BackgroundTransparency = 1 }):Play()
									ts:Create(cb, ti3, { Transparency = 1 }):Play()
									c1.Position = UDim2.new(0.613, 0, 0.771, 0)
									c2.Position = UDim2.new(0.613, 0, 0.879, 0)
									c1.Visible = false
									c2.Visible = false
									mf.Visible = false
									pt = false
									bc1 = false
									bc2 = false
									wait(1)
									bc3 = true
								end
							end)
						end
					end)
					c2.MouseButton1Click:Connect(function()
						if bc2 == false then
							bc2 = true
							print("no")
							typewrite(dialog, "Goodbye", 0.07)
							ts:Create(c1, ti3, { Transparency = 1 }):Play()
							ts:Create(c2, ti3, { Transparency = 1 }):Play()
							ts:Create(mf, ti3, { Transparency = 1 }):Play()
							ts:Create(cb, ti3, { Transparency = 1 }):Play()
							ts:Create(dialog, ti3, { TextTransparency = 1 }):Play()
							ts:Create(name, ti3, { TextTransparency = 1 }):Play()
							ts:Create(Npcimage, ti3, { ImageTransparency = 1 }):Play()
							ts:Create(Npcimage, ti3, { BackgroundTransparency = 1 }):Play()
							ts:Create(cb, ti3, { Transparency = 1 }):Play()
							wait(2)
							c1.Position = UDim2.new(0.613, 0, 0.771, 0)
							c2.Position = UDim2.new(0.613, 0, 0.879, 0)
							c1.Visible = false
							c2.Visible = false
							mf.Visible = false
							pt = false
							bc1 = false
							bc2 = false
						end
					end)
				end
			end)
		end
	end
end)

(Manager)

local Manager = {}

Manager.Profiles = {} --profile, storing data

function Manager.AdjustOre(player: Player, amount: number)
	local profile = Manager.Profiles[player]
	if not profile then return end
	profile.Data.Ores += amount
	player.leaderstats.Ore.Value = profile.Data.Ores
end

function Manager.AdjustMoney(player: Player, amount: number)
	local profile = Manager.Profiles[player]
	if not profile then return end
	profile.Data.Money += amount
	player.leaderstats.Money.Value = profile.Data.Money
end

function Manager.SellOre(player: Player, Multiplier: number)
	local profile = Manager.Profiles[player]
	if not profile then return end
	profile.Data.Money += profile.Data.Ores*Multiplier
	profile.Data.Ores = 0
	player.leaderstats.Money.Value = profile.Data.Money
	player.leaderstats.Ore.Value = profile.Data.Ores
end

return Manager

(Sell)

local player = game.Players.LocalPlayer
local sss = script.Parent
local pd = sss.PlayerData
local data = pd.Data
local manager = require(pd.Manager)
local rs = game:GetService("ReplicatedStorage")
local oreevent = rs.GetOre
local oremultiplier = math.random(1.1, 2)
local pickstrength = require(pd.Pickaxe)
local wpick = pickstrength.woodpick
local sc = rs.ServerConnector
local sell = rs.Sell

local function addore(player: Player)
	manager.AdjustOre(player, 1*oremultiplier)
	oremultiplier = math.random(1.1, 2)
	print("success")
end

local function sellore(player: Player)
	manager.SellOre(player, 0.1)
	print("sold")
end

sc.OnServerEvent:Connect(addore)
sell.OnServerEvent:Connect(sellore)

How would i show it? I would appreciate the help

2 Likes

You could make a function called GetPrice which takes in the player and the multiplier

And then this can be called by server to find the price of the ores?

thanks, i tried it and it works
(character req)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.