So I have this scavenger hunt game where you find Pots. Your objective is to get them all. However, there’s an issue, and that being that when someone collects a Pot, another player gets it for some reason. This has never happened before, and the game has been up for probably a year by now. What could possibly be the issue?
Local script for collecting pots:
wait(1)
local HumanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")
local Pots = game.Workspace:WaitForChild("Pots")
local BadgeService = game:GetService("BadgeService")
local player = game.Players.LocalPlayer
local userid = player.UserId
local CollectedData
game.ReplicatedStorage.AskForCollected:FireServer()
game.ReplicatedStorage.SendOutData.OnClientEvent:Connect(function(data)
if data ~= nil then
CollectedData = data
end
end)
debounce = false
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:Connect(function(hit)
if hit.Parent == workspace.Pots and debounce == false then
debounce = true
game.ReplicatedStorage.AskForCollected:FireServer()
game.ReplicatedStorage.SendOutData.OnClientEvent:Wait(function(data)
if data ~= nil then
CollectedData = data
end
end)
local plr = game.Players.LocalPlayer
local human = script.Parent:WaitForChild("Humanoid")
local GUI = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("CollectGui").Text
local badge = hit.BadgeID.Value
if CollectedData[hit.Name].Collected == true then
game.StarterGui:SetCore("SendNotification", {
Title = "Already found",
Text = "You already found "..hit.Name,
Icon = hit.Decal.Texture
})
game.ReplicatedStorage.GiveBadge:FireServer(badge)
wait(1)
debounce = false
else
if hit.Difficulty.Value == "Very Easy" then
GUI.Parent.Difficulty.Text = hit.Difficulty.Value
GUI.LayoutOrder = -30
GUI.Parent.Difficulty.TextColor3 = Color3.fromRGB(179, 255, 165)
elseif hit.Difficulty.Value == "Easy" then
GUI.Parent.Difficulty.Text = hit.Difficulty.Value
GUI.LayoutOrder = -20
GUI.Parent.Difficulty.TextColor3 = Color3.fromRGB(0, 180, 0)
elseif hit.Difficulty.Value == "Medium" then
GUI.Parent.Difficulty.Text = hit.Difficulty.Value
GUI.LayoutOrder = -10
GUI.Parent.Difficulty.TextColor3 = Color3.fromRGB(255, 255, 0)
elseif hit.Difficulty.Value == "Hard" then
GUI.Parent.Difficulty.Text = hit.Difficulty.Value
GUI.LayoutOrder = 0
GUI.Parent.Difficulty.TextColor3 = Color3.fromRGB(255, 0, 0)
elseif hit.Difficulty.Value == "Rough" then
GUI.Parent.Difficulty.Text = hit.Difficulty.Value
GUI.LayoutOrder = 10
GUI.Parent.Difficulty.TextColor3 = Color3.fromRGB(131, 128, 144)
elseif hit.Difficulty.Value == "Insane" then
GUI.Parent.Difficulty.Text = hit.Difficulty.Value
GUI.LayoutOrder = 20
GUI.Parent.Difficulty.TextColor3 = Color3.fromRGB(0, 22, 255)
elseif hit.Difficulty.Value == "EXTREME" then
GUI.Parent.Difficulty.Text = hit.Difficulty.Value
GUI.LayoutOrder = 30
GUI.Parent.Difficulty.TextColor3 = Color3.fromRGB(0, 161, 254)
elseif hit.Difficulty.Value == "HORRIBLE" then
GUI.Parent.Difficulty.Text = hit.Difficulty.Value
GUI.LayoutOrder = 40
GUI.Parent.Difficulty.TextColor3 = Color3.fromRGB(0, 243, 255)
elseif hit.Difficulty.Value == "U̴̯̦͐̽Ň̸̩̕H̸̪̳̮́Ȩ̴͒̍A̵̫̋̂̍͜V̸̨̢̺̇È̸̦͔̞̓̌Ń̵̮̭̅L̶͉̐̚Y̷̛͇͐͌" then
GUI.Parent.Difficulty.Text = hit.Difficulty.Value
GUI.LayoutOrder = 50
GUI.Parent.Difficulty.TextColor3 = Color3.fromRGB(130, 7, 0)
end
game.ReplicatedStorage.SendInCollected:FireServer(hit.Name)
game.Workspace.CollectBadgeID.Value = badge
game.ReplicatedStorage.Badge:FireServer(badge, hit.Name)
game.StarterGui:SetCore("SendNotification", {
Title = hit.Name,
Text = "Nice, you found "..hit.Name,
Icon = hit.Decal.Texture,
})
game.ReplicatedStorage.AskForCollected:FireServer()
game.ReplicatedStorage.SendOutData.OnClientEvent:Wait(function(data)
if data ~= nil then
CollectedData = data
end
end)
wait(1)
debounce = false
end
end
end)
end
end
Server script for data saving and other fun doohickeys:
local ds = game:GetService("DataStoreService"):GetDataStore("PlayerDataNQ3")
_G.PlayerData = {}
game.Players.PlayerAdded:Connect(function(plr)
_G.PlayerData[plr.UserId] = {
Collected = {
["1,000 Visits Pot"] = {
Collected = false
},
["AWOOGA"] = {
Collected = false
},
["Badly Made Pot"] = {
Collected = false
},
["Banned Pot"] = {
Collected = false
},
["Broken Pot"] = {
Collected = false
},
["Burning Pot"] = {
Collected = false
},
["Candy Corn Pot"] = {
Collected = false
},
["Candy King Pot"] = {
Collected = false
},
["Cartoon Pot"] = {
Collected = false
},
["Chalkboard Pot"] = {
Collected = false
},
["Cheese Pot"] = {
Collected = false
},
["Coin Pot"] = {
Collected = false
},
["Cookie Pot"] = {
Collected = false
},
["Dancing Pot"] = {
Collected = false
},
["Dialogue Pot"] = {
Collected = false
},
["Donut Pot"] = {
Collected = false
},
["Driving Pot"] = {
Collected = false
},
["Encoded Pot"] = {
Collected = false
},
["Falling Pot"] = {
Collected = false
},
["Farmer Pot"] = {
Collected = false
},
["Flame Pot"] = {
Collected = false
},
["Flappy Pot"] = {
Collected = false
},
["Flower Pot"] = {
Collected = false
},
["Gamer Pot"] = {
Collected = false
},
["Gem Pot"] = {
Collected = false
},
["Gingerbread Pot"] = {
Collected = false
},
["Graffiti Pot"] = {
Collected = false
},
["Grassy Pot"] = {
Collected = false
},
["Guard Pot"] = {
Collected = false
},
["Happy Home Pot"] = {
Collected = false
},
["Hay Pot"] = {
Collected = false
},
["Hot Chocolate Pot"] = {
Collected = false
},
["Hyper Secret Pot"] = {
Collected = false
},
["Ice Cream Pot"] = {
Collected = false
},
["Juice Pot"] = {
Collected = false
},
["Lava Pot"] = {
Collected = false
},
["Lollipop Pot"] = {
Collected = false
},
["Magma Pot"] = {
Collected = false
},
["Marshmallow Pot"] = {
Collected = false
},
["Melted Pot"] = {
Collected = false
},
["Miner Pot"] = {
Collected = false
},
["Nerd Pot"] = {
Collected = false
},
["Neon Pot"] = {
Collected = false
},
["Noob Pot"] = {
Collected = false
},
["Normal Pot"] = {
Collected = false
},
["Obby Pot"] = {
Collected = false
},
["Orange Pot"] = {
Collected = false
},
["Paint Splattered Pot"] = {
Collected = false
},
["Pig Pot"] = {
Collected = false
},
["Pixelated Pot"] = {
Collected = false
},
["Plushie Pot"] = {
Collected = false
},
["Pot JR."] = {
Collected = false
},
["Pot That Has Hippopotomonstrososesquippedaliophobia"] = {
Collected = false
},
["Potbux"] = {
Collected = false
},
["Pro Pot"] = {
Collected = false
},
["Rainbow Secret Pot"] = {
Collected = false
},
["Realistic Pot"] = {
Collected = false
},
["Red Pot"] = {
Collected = false
},
["Reset Pot"] = {
Collected = false
},
["Rest In Potses"] = {
Collected = false
},
["Rich Pot"] = {
Collected = false
},
["Ruler Pot"] = {
Collected = false
},
["Scribble Pot"] = {
Collected = false
},
["Secret Pot"] = {
Collected = false
},
["Shiny Pot"] = {
Collected = false
},
["Stopping Pot"] = {
Collected = false
},
["Stud Pot"] = {
Collected = false
},
["Super Secret Pot"] = {
Collected = false
},
["Template Pot"] = {
Collected = false
},
["Ticket Pot"] = {
Collected = false
},
["Traveling Pot"] = {
Collected = false
},
["Un-Secret Pot"] = {
Collected = false
},
["White Pot"] = {
Collected = false
},
["Yellow Pot"] = {
Collected = false
},
["Zombpot"] = {
Collected = false
},
["Picnic Pot"] = {
Collected = false
},
["Chilling Pot"] = {
Collected = false
},
["Ant Pot"] = {
Collected = false
},
["Wish Pot"] = {
Collected = false
},
["Water Pot"] = {
Collected = false
},
["poot"] = {
Collected = false
},
["Dreadful Pot"] = {
Collected = false
},
["Shattered Pot"] = {
Collected = false
},
["potsjal"] = {
Collected = false
},
["Super Ultra Miniature Nonexistent Tiny Pot"] = {
Collected = false
},
["Blarret Pot"] = {
Collected = false
},
["Sunburnt Pot"] = {
Collected = false
},
["Coral Pot"] = {
Collected = false
},
["Fish Pot"] = {
Collected = false
},
["Swimming Pot"] = {
Collected = false
},
["Cybernetic Pot"] = {
Collected = false
},
["Dementia Pot"] = {
Collected = false
},
["All-Seeing Pot"] = {
Collected = false
},
["Star Pot"] = {
Collected = false
},
["Voidstruck Pot"] = {
Collected = false
},
["Inverted Pot"] = {
Collected = false
},
}
}
local data = _G.PlayerData[plr.UserId]
local save = ds:GetAsync(plr.UserId)
if save then
for i, v in pairs(save.Collected) do
if data.Collected[i] then
else
data.Collected[i] = {
Collected = false
}
end
end
for i, v in pairs(data.Collected) do
if save.Collected[i] then
else
save.Collected[i] = {
Collected = false
}
end
end
for i,v in pairs(save.Collected) do
data.Collected[i] = v
end
end
end)
game.ReplicatedStorage.AskForCollected.OnServerEvent:Connect(function(player)
local CollectedTable = _G.PlayerData[player.UserId].Collected
game.ReplicatedStorage.SendOutData:FireClient(player, CollectedTable)
end)
game.ReplicatedStorage.SendInCollected.OnServerEvent:Connect(function(player, pot)
_G.PlayerData[player.UserId].Collected[pot].Collected = true
print(player.UserId)
end)
game.Players.PlayerRemoving:Connect(function(plr)
local save = ds:GetAsync(plr.UserId)
if save ~= _G.PlayerData[plr.UserId] then
ds:SetAsync(plr.UserId,_G.PlayerData[plr.UserId])
end
_G.PlayerData[plr.UserId] = nil
end)
game:BindToClose(function()
for i, plr in pairs(game.Players:GetChildren()) do
local save = ds:GetAsync(plr.UserId)
if save ~= _G.PlayerData[plr.UserId] then
ds:SetAsync(plr.UserId,_G.PlayerData[plr.UserId])
end
_G.PlayerData[plr.UserId] = nil
end
end)
I’m looking for solutions to simply just THIS. I do not wish for any other things that don’t relate to my issue.