Something Is Deleting Int-Value

You can write your topic however you want, but you need to answer these questions:

  1. **What do you want to achieve?**Im making a game from a tutorial, But something is deleting a int-value. I checked and there was no deleting script for it.

  2. What is the issue? Something Is Deleting Int-Value

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? Yes.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Here are some scripts that might be related to it: first script: ``` local Players = game:GetService(“Players”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local runService = game:GetService(“RunService”)
local physicsService = game:GetService(“PhysicsService”)
local userInputService = game:GetService(“UserInputService”)

local Events = ReplicatedStorage:WaitForChild(“Events”)
local Functions = ReplicatedStorage:WaitForChild(“Functions”)
local RequestTowerFunction = Functions:WaitForChild(“RequestTower”)
local Towers = ReplicatedStorage:WaitForChild(“Towers”)
local SpawnTowerEvent = Events:WaitForChild(“SpawnTower”)

local Gold = Players.LocalPlayer:WaitForChild(“Gold”)

local camera = game.Workspace.CurrentCamera
local Gui = script.Parent
local towerToSpawn = nil
local canPlace = false
local rotation = 0

local placedTowers = 0
local maxTowers = 75

local function UpdateGold()
Gui.Gold.Text = "Gold: " … Gold.Value
end

UpdateGold()

Gold.Changed:Connect(UpdateGold)

local function mouseRaycast(blacklist)
local mousePosition = userInputService:GetMouseLocation()

local mouseRay = camera:ViewportPointToRay(mousePosition.X, mousePosition.Y)
local raycastParams = RaycastParams.new()

raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = blacklist

local raycastResult = workspace:Raycast(mouseRay.Origin, mouseRay.Direction * 1000, raycastParams)

return raycastResult

end

local function RemovePlaceHolderTower()
if towerToSpawn then
towerToSpawn:Destroy()
towerToSpawn = nil
end
end

local function AddPlaceHolderTower(name)
RemovePlaceHolderTower()
local TowerExists = Towers:FindFirstChild(name)
if TowerExists then
towerToSpawn = TowerExists:Clone()
towerToSpawn.Parent = workspace

	for i, object in ipairs(towerToSpawn:GetDescendants()) do
		if object:IsA("BasePart") then
			physicsService:SetPartCollisionGroup(object, "Tower")
			object.Transparency = 0.5
		end
	end
end

end

local function colorPlaceHolderTower(color)
for i, object in ipairs(towerToSpawn:GetDescendants()) do
if object:IsA(“BasePart”) then
object.Color = color
end
end
end

Gui.Towers.Title.Text = “Towers:” … placedTowers … “/” … maxTowers

for i, tower in pairs(Towers:GetChildren()) do
local Button = Gui.Towers.Template:Clone()
local config = tower:WaitForChild(“Config”)
Button.Name = tower.Name
Button.Image = config.Image.Texture
Button.Visible = true
Button.LayoutOrder = config.Price.Value
Button.Price.Text = config.Price.Value

Button.Parent = Gui.Towers


Button.Activated:Connect(function()
	local allowedToSpawn = RequestTowerFunction:InvokeServer(tower.Name)
	if allowedToSpawn then
		AddPlaceHolderTower(Button.Name)
	end
end)

end

userInputService.InputBegan:Connect(function(input, processed)
if processed then
return
end

if towerToSpawn then
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if canPlace then
			SpawnTowerEvent:FireServer(towerToSpawn.Name, towerToSpawn.PrimaryPart.CFrame)
			placedTowers += 1
			RemovePlaceHolderTower()
			Gui.Towers.Title.Text = "Towers:" .. placedTowers .. "/" .. maxTowers
		end
		
	elseif input.KeyCode == Enum.KeyCode.R then
		rotation += 90
	end
end

end)

runService.RenderStepped:Connect(function()
if towerToSpawn then
local result = mouseRaycast({towerToSpawn})
if result and result.Instance then
if result.Instance.Parent.Name == “TowerArea” then
canPlace = true
colorPlaceHolderTower(Color3.new(0,1,0))
else
canPlace = false
colorPlaceHolderTower(Color3.new(1,0,0))
end
local x = result.Position.X
local y = result.Position.Y + towerToSpawn.Humanoid.HipHeight + (towerToSpawn.PrimaryPart.Size.Y / 2)
local z = result.Position.Z

		local cframe = CFrame.new(x, y, z) * CFrame.Angles(0, math.rad(rotation), 0)
		towerToSpawn:SetPrimaryPartCFrame(cframe)		
	end		
end

end)
Second Script: local Tower = {}

local ServerStorage = game:GetService(“ServerStorage”)
local PhysicsService = game:GetService(“PhysicsService”)
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local Functions = ReplicatedStorage:WaitForChild(“Functions”)

local RequestTowerFunction = Functions:WaitForChild(“RequestTower”)

local maxTowers = 75

function FindNearestTarget(tower, range)

local maxDistance = range
local nearestTarget = nil

for i, target in ipairs(workspace.Mobs:GetChildren()) do
	local distance = (target.HumanoidRootPart.Position - tower.HumanoidRootPart.Position).Magnitude
	if distance < maxDistance then
		nearestTarget = target
		range = distance
	end
end

return nearestTarget

end

function Tower.Attack(newTower, player)
local config = newTower.Config
local target = FindNearestTarget(newTower, config.Range.Value)

if target and target:FindFirstChild("Humanoid") and target.Humanoid.Health > 0 then
	
	
	local targetCFrame = CFrame.lookAt(newTower.HumanoidRootPart.Position,target.HumanoidRootPart.Position)
	newTower.HumanoidRootPart.BodyGyro.CFrame = targetCFrame
	
	ReplicatedStorage.Events.AnimateTower:FireAllClients(newTower, "Attack")
	target.Humanoid:TakeDamage(config.Damage.Value)
	
	if target.Humanoid.Health <= 0 then
		player.Gold.Value += target.Humanoid.MaxHealth + 10
	end
	
	task.wait(config.Cooldown.Value)
end

task.wait(0.1)

Tower.Attack(newTower, player)

end

function Tower.Spawn(player, name, cframe)
local AllowedToSpawn = Tower.CheckSpawn(player, name)

if AllowedToSpawn then
	local newTower = ReplicatedStorage.Towers[name]:Clone()
	newTower.HumanoidRootPart.CFrame = cframe
	newTower.Parent = workspace.Towers
	newTower.HumanoidRootPart:SetNetworkOwner(nil)
	
	local bodyGryo = Instance.new("BodyGyro")
	bodyGryo.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
	bodyGryo.D = 0
	bodyGryo.CFrame = newTower.HumanoidRootPart.CFrame
	bodyGryo.Parent = newTower.HumanoidRootPart

	for i, object in ipairs(newTower:GetDescendants()) do
		if object:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(object, "Tower")
		end
	end
	
	player.Gold.Value -= newTower.Config.Price.Value
	player.PlacedTowers.Value += 1
	
	coroutine.wrap(Tower.Attack)(newTower, player)

else
warn("Tower Doesnts Exist: ", name)
end
end

ReplicatedStorage.Events.SpawnTower.OnServerEvent:Connect(Tower.Spawn)

function Tower.CheckSpawn(player, name)
local towerExists = ReplicatedStorage.Towers:FindFirstChild(name)

if towerExists then
	if towerExists.Config.Price.Value <= player.Gold.Value then
		if player.PlacedTowers.Value < maxTowers then
			return true
		else
			warn("Player Has Reached Max Limited")
		end
	else
		warn("Player Cannot Afford")
	end
else
	warn("Tower Doesnt Exist.")
end

return false

end

RequestTowerFunction.OnServerInvoke = Tower.CheckSpawn

return Tower Last Script: local PhysicsService = game:GetService(“PhysicsService”)
local DataStoreService = game:GetService(“DataStoreService”)
local BadgeService = game:GetService(“BadgeService”)

local PlayerData = DataStoreService:GetDataStore(“PlayerData”)

game.Players.PlayerAdded:Connect(function(player)

local gold = Instance.new("IntValue")
gold.Name = "Gold"
gold.Value = 250
gold.Parent = player

local placedTowers = Instance.new("IntValue")
gold.Name = "PlacedTowers"
gold.Value = 0
gold.Parent = player

player.CharacterAdded:Connect(function(character)
	for i, object in ipairs(character:GetDescendants()) do
		if object:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(object, "Player")
		end
	end
end)

end)

this part is setting again the gold parent, name and value, instead of “placedTowers”. Change it to “placedTowers” and maybe that solves the issue

bruh ok i was blind lmao how did i not see that