Simulator Door Problem

Hello forummers, I’ve been working on this simulator game and i decided to implement a door system that unlocks to another area (basically like pet sim). It should be working, but the game system i use to format numbers makes my currency data have letters in it. like so:

image

this is where my door system comes in, it basically only searches for a number, so im getting this error:
image

How can i make it so that i can still purchase the doors even with the formatter?

this is the script which the error is coming from:

local workSpace = game:GetService("Workspace")
local playerS = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")

local player = playerS.LocalPlayer
local char = workSpace[player.Name]



for i,v in pairs(workSpace:WaitForChild("Doors"):GetChildren()) do
	
	local surfCost = v:WaitForChild("SurfaceGui"):WaitForChild("Cost")
	local surfClose = v:WaitForChild("SurfaceGui"):WaitForChild("Close")
	local surf = v:WaitForChild("SurfaceGui")
	
	v.Anchored = true
	surfCost.Text = script:WaitForChild(v.Name).Value.."$"
	if player:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild(script:WaitForChild("Settings"):WaitForChild("Currency").Value).Value >= script:WaitForChild(v.Name).Value and player:WaitForChild("Doors"):WaitForChild(v.Name).Value ~= true then
		surfCost.TextColor3 = script:WaitForChild("Settings"):WaitForChild("DoorTextColorIfEnoughMoney").Value
		surfClose.TextColor3 = script:WaitForChild("Settings"):WaitForChild("DoorTextColorIfEnoughMoney").Value
		v.Color = script:WaitForChild("Settings"):WaitForChild("DoorColorBeforeBuy").Value
	elseif player:WaitForChild("Doors"):WaitForChild(v.Name).Value == true then
		surfCost.Visible = false
		surfClose.Visible = false
		v.Transparency = 0.3
		v.CanCollide = false
		v.Color = script:WaitForChild("Settings"):WaitForChild("DoorColorAfterBuy").Value		
	end
end



player:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild(script:WaitForChild("Settings"):WaitForChild("Currency").Value).Changed:Connect(function()
	for i,v in pairs(workSpace:WaitForChild("Doors"):GetChildren()) do
		
	local surfCost = v:WaitForChild("SurfaceGui"):WaitForChild("Cost")
	local surfClose = v:WaitForChild("SurfaceGui"):WaitForChild("Close")
	local surf = v:WaitForChild("SurfaceGui")
		
	v.Anchored = true
	surfCost.Text = script:WaitForChild(v.Name).Value.."$"
	if player:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild(script:WaitForChild("Settings"):WaitForChild("Currency").Value).Value >= script:WaitForChild(v.Name).Value and player:WaitForChild("Doors"):WaitForChild(v.Name).Value ~= true then
		surfCost.TextColor3 = script:WaitForChild("Settings"):WaitForChild("DoorTextColorIfEnoughMoney").Value
		surfClose.TextColor3 = script:WaitForChild("Settings"):WaitForChild("DoorTextColorIfEnoughMoney").Value
		v.Color = script:WaitForChild("Settings"):WaitForChild("DoorColorBeforeBuy").Value
	elseif player:WaitForChild("Doors"):WaitForChild(v.Name).Value == true then
		surfCost.Visible = false
		surfClose.Visible = false
		v.Transparency = 0.3
		v.CanCollide = false
		v.Color = script:WaitForChild("Settings"):WaitForChild("DoorColorAfterBuy").Value
	elseif player:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild(script:WaitForChild("Settings"):WaitForChild("Currency").Value).Value < script:WaitForChild(v.Name).Value and player:WaitForChild("Doors"):WaitForChild(v.Name).Value ~= true then		
			surfCost.TextColor3 = script:WaitForChild("Settings"):WaitForChild("DoorTextColorIfNotEnoughMoney").Value
			surfClose.TextColor3 = script:WaitForChild("Settings"):WaitForChild("DoorTextColorIfNotEnoughMoney").Value
			v.Color = script:WaitForChild("Settings"):WaitForChild("DoorColorBeforeBuy").Value
		end
	end
end)
local did = true
local can = true
replicatedStorage:WaitForChild("DoorEvents"):WaitForChild("Door").OnClientEvent:Connect(function(door)
	if player:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild(script:WaitForChild("Settings"):WaitForChild("Currency").Value).Value >= script:WaitForChild(door).Value and player:WaitForChild("Doors"):WaitForChild(door).Value ~= true then
		if did == true and can == true then
		script.Parent:WaitForChild("BuyDoor"):WaitForChild("ActualDoor").Value = door
		script.Parent:WaitForChild("BuyDoor"):WaitForChild("BuyDoor"):WaitForChild("Desc").Text = "Are you SURE you want to buy this door for "..script:WaitForChild(door).Value.."$"
		script.Parent:WaitForChild("BuyDoor"):WaitForChild("BuyDoor"):TweenPosition(UDim2.new(0.5,0,0.5,0), "In", "Back", 2)
		did = false
		can = false
		end
	end
end)

script.Parent:WaitForChild("BuyDoor"):WaitForChild("BuyDoor"):WaitForChild("Back").MouseButton1Click:Connect(function()
	local door = script.Parent:WaitForChild("BuyDoor"):WaitForChild("ActualDoor").Value
	replicatedStorage:WaitForChild("DoorEvents"):WaitForChild("Buy"):FireServer(door, script:WaitForChild("Settings"):WaitForChild("Currency").Value, script:WaitForChild(door).Value)
	script.Parent:WaitForChild("BuyDoor"):WaitForChild("BuyDoor"):TweenPosition(UDim2.new(-1.5,0,0.5,0), "Out", "Back", 2)

	did = true
	can = true
end)

script.Parent:WaitForChild("BuyDoor"):WaitForChild("BuyDoor"):WaitForChild("Close").MouseButton1Click:Connect(function()
	script.Parent:WaitForChild("BuyDoor"):WaitForChild("BuyDoor"):TweenPosition(UDim2.new(-1.5,0,0.5,0), "Out", "Back", 1)

	can = true
	did = true
end)



replicatedStorage:WaitForChild("DoorEvents"):WaitForChild("ChangeDoor").OnClientEvent:Connect(function(door)
		workSpace:WaitForChild("Doors"):WaitForChild(door):WaitForChild("SurfaceGui"):WaitForChild("Cost").Visible = false
		workSpace:WaitForChild("Doors"):WaitForChild(door):WaitForChild("SurfaceGui"):WaitForChild("Close").Visible = false
		workSpace:WaitForChild("Doors"):WaitForChild(door).Transparency = 0.3
		workSpace:WaitForChild("Doors"):WaitForChild(door).CanCollide = false
		workSpace:WaitForChild("Doors"):WaitForChild(door).Color = script:WaitForChild("Settings"):WaitForChild("DoorColorAfterBuy").Value
end)

the error is coming from this line:

	if player:WaitForChild("Data"):WaitForChild("Stats"):WaitForChild(script:WaitForChild("Settings"):WaitForChild("Currency").Value).Value >= script:WaitForChild(v.Name).Value and player:WaitForChild("Doors"):WaitForChild(v.Name).Value ~= true then

Turn the string value into a number value, because having 0;5406 money in your pocket isn’t ideal and isn’t even a number.

2 Likes