Im having issues with a script, according to this script, wiscount exists, but according to a localscript tied to this one it doesnt. There is another script in the game that does the same function as this, but for a different counter.
local DSS = game:GetService("DataStoreService")
local CS = game:GetService("CollectionService")
local RS = game:GetService("ReplicatedStorage")
local BS = game:GetService("BadgeService")
local Players = game:GetService("Players")
local touchPartsTag = "Wisdom_Counter_Parts"
local clickPartsTag = "Wisdom_Counter_ClickParts"
local countDS = DSS:GetDataStore("WisdomCounterV_Testing")
local badgeId = 2143677101
local touchParts = workspace.WisdomBurgers:GetChildren()
local clickParts = workspace.WisdomBurgers:GetChildren()
local wisdomIds = require(script:WaitForChild("WisdomIds"))
local total = #wisdomIds
local players = {}
local remotes = RS:WaitForChild("WisdomRemotes")
local counterInfo = remotes:FindFirstChild("CounterInfo")
local updateCounter = remotes:FindFirstChild("UpdateCounter")
function playerAdded(plr)
local wiscount = {}
local success, response = pcall(function()
wiscount = countDS:GetAsync(plr.UserId.."-wiscount") or {}
end)
for i, v in pairs(wiscount) do
if not table.find(wisdomIds, v) then
table.remove(wiscount, i)
print("rem")
end
print("remn")
end
players[plr.Name] = {}
players[plr.Name].wiscount = wiscount
end
function playerRemoving(plr)
if players[plr.Name] then
countDS:SetAsync(plr.UserId.."-wiscount", players[plr.Name].wiscount)
else
local wiscount = {}
local success, reponse = pcall(function()
wiscount = countDS:GetAsync(plr.UserId.."-wiscount") or {}
end)
local success, response = pcall(function()
countDS:SetAsync(plr.UserId.."-wiscount", wiscount)
end)
end
end
function counterInfoInvoke(plr, request)
if request == "Total" then
return total
end
if request == "wiscount" then
if not players[plr.Name].wiscount then return "Error: Count not found" end
return players[plr.Name].wiscount
end
end
function init()
print("t1")
game.Players.PlayerAdded:Connect(playerAdded)
counterInfo.OnServerInvoke = counterInfoInvoke
game.Players.PlayerRemoving:Connect(playerRemoving)
print("t1a")
for i, v in pairs(touchParts) do
print("t2")
if not v:GetAttribute("WisdomId") then continue end
print("t3")
v.Touched:Connect(function(hit)
print("t4")
if Players:GetPlayerFromCharacter(hit.Parent) then
print("t5")
local plr = Players:GetPlayerFromCharacter(hit.Parent)
if #players[plr.Name].wiscount >= total then return end
print("t5a")
if table.find(players[plr.Name].wiscount, v:GetAttribute("WisdomId")) then return end
print("t5b")
if not table.find(wisdomIds, v:GetAttribute("WisdomId")) then return end
print("t5c")
table.insert(players[plr.Name].wiscount, v:GetAttribute("WisdomId"))
updateCounter:FireClient(plr, players[plr.Name].wiscount)
if #players[plr.Name].wiscount == total then
BS:AwardBadge(plr.UserId, badgeId)
end
end
end)
end
for i, v in pairs(clickParts) do
print("t6")
if not v:GetAttribute("WisdomId") then continue end
print("t7")
if v:FindFirstChild("ClickDetector") then
print("t8")
v.ClickDetector.MouseClick:Connect(function(plr)
print("t9")
if #players[plr.Name].wiscount >= total then return end
if table.find(players[plr.Name].wiscount, v:GetAttribute("WisdomId")) then return end
table.insert(players[plr.Name].wiscount, v:GetAttribute("WisdomId"))
updateCounter:FireClient(plr, players[plr.Name].wiscount)
if #players[plr.Name].wiscount == total then
BS:AwardBadge(plr.UserId, badgeId)
end
end)
end
end
end
init()