Why is it not actually adding value to the player

it is a normal script so why is it not adding 5000 to the server and client

script.Parent.ChildAdded:Connect(function(child)
		print(child.Name)
end)

local debris = game:GetService("Debris")
local Crate = game.ReplicatedStorage:WaitForChild("Crate")
local GoldenCrate = game.ReplicatedStorage:WaitForChild("GoldenCrate")
local Sound = game:GetService("SoundService"):WaitForChild("CrateSound")

local db = false

local function AddCrate()
	local newCrate
	local spawns = script.Parent:GetChildren()

	-- Filter out only the parts named "Spawn"
	local validSpawns = {}
	for _, spawn in ipairs(spawns) do
		if spawn:IsA("BasePart") and spawn.Name == "Spawn" then
			table.insert(validSpawns, spawn)
		end
	end

	-- Check if there are valid spawn points
	if #validSpawns > 0 then
		local randomSpawn = math.random(1, #validSpawns)
		local chosenSpawn = validSpawns[randomSpawn]

		-- Determine crate type (regular or golden) based on a 35% chance
		local isGoldenCrate = math.random() <= 0.35

		if isGoldenCrate then
			newCrate = GoldenCrate:Clone()
		else
			newCrate = Crate:Clone()
		end
		newCrate.Parent = workspace.CrateSpawns
		newCrate:PivotTo(chosenSpawn.CFrame)
	else
		warn("No valid spawn points named 'Spawn' found.")
		return
	end

	newCrate.Hitbox.Touched:Connect(function(hit)
		local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

		if player and db == false then
			local leaderstats = player:WaitForChild("leaderstats")
			local Money = leaderstats:FindFirstChild("Money")

			Money.Value += newCrate.Value.Value
			Sound:Play()
			db = true
			newCrate:Destroy()
			task.wait(1)
			db = false
		end
	end)

	debris:AddItem(newCrate, 35)
end

while wait(60) do
	AddCrate()
end


Did it prints, warns, or errors anything in Output or Developer Console?

nope nothing the script is inside serverscriptservice and yes all of the variables are right

I fixed it forgot i had a function to get and set money

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