.Touched:Connect doesn't working

I’m quite annoyed, there is no problem with it because it does not work. This ModuleScript should work a part, but it doesn’t, it doesn’t do anything or anything

local Players = game:GetService("Players")

local DataManager = require(game.ReplicatedStorage:WaitForChild("DataManager"))

local part = workspace:WaitForChild("Dinero")

local function onTouched(TouchedPart)
	print("adsadaddaqdadadadd")
	if TouchedPart.Parent:IsA("Model") and TouchedPart.Parent.Humanoid then
		local character = TouchedPart.Parent
		local player = Players:playerFromCharacter(character)

		if player then
			local data = DataManager:Get(player)

			if data then
				local currentTime = os.time()
				local timeSinceLastUsedMoneyPart = currentTime - data.LastUsedDineroPartTime
				local waitTime = 10 * 60

				if timeSinceLastUsedMoneyPart > waitTime then
					data.LastUsedDineroPartTime = currentTime
					data.Dinero += 500
					print(player.Name, "ahora tiene dinero", data.Dinero)
				else
					print(player.Name, "debe de esperar para usar:", waitTime - timeSinceLastUsedMoneyPart)
				end
			else
				print(player.Name, "no tiene perfil cargado")
			end
		end
	end
end

part.Touched:Connect(onTouched)
--This moduleScript is located in replicatedStorage
local Players = game:GetService("Players")

local DataManager = require(game.ReplicatedStorage:WaitForChild("DataManager"))

local part = workspace:WaitForChild("Dinero")

local function onTouched(TouchedPart)
	print("adsadaddaqdadadadd")
	if TouchedPart.Parent:IsA("Model") and TouchedPart.Parent.Humanoid then
		local character = TouchedPart.Parent
		local player = Players:playerFromCharacter(character)

		if player then
			local data = DataManager:Get(player)

			if data then
				local currentTime = os.time()
				local timeSinceLastUsedMoneyPart = currentTime - data.LastUsedDineroPartTime
				local waitTime = 10 * 60

				if timeSinceLastUsedMoneyPart > waitTime then
					data.LastUsedDineroPartTime = currentTime
					data.Dinero += 500
					print(player.Name, "ahora tiene dinero", data.Dinero)
				else
					print(player.Name, "debe de esperar para usar:", waitTime - timeSinceLastUsedMoneyPart)
				end
			else
				print(player.Name, "no tiene perfil cargado")
			end
		end
	end
end

part.Touched:Connect(function(hit)
onTouched(hit)
end)
2 Likes