So I am trying to create a Find The… game in which you have to find the memes, but my collection system is not working.
Collection script:
local meme = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MemeList = ReplicatedStorage:WaitForChild("Memes")
local Baller = MemeList:WaitForChild("Baller")
meme.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player then
local collectedFile = player.MemesCollected
local found = collectedFile:FindFirstChild("Baller") -- I think this the problem line
print(found) -- Prints "nil"
end
end
end)
Whenever the meme is touched, it should add it to a folder parented to the player.
I think what it’s doing is it’s searching for the Baller value and it thinks it should already be in the folder, even though it’s not. If this is the problem, I’m just not sure how to fix it.
Any help is appreciated! Thank you and have a wonderful day!
local meme = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MemeList = ReplicatedStorage:WaitForChild("Memes")
local Baller = MemeList:WaitForChild("Baller")
meme.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player then
local collectedFile = player.MemesCollected
local found = collectedFile:FindFirstChild("Baller").Value -- I think this the problem line
print(found) -- Prints "nil"
end
end
end)
You are correct, the findfirstchild is returning nil because “baller” isn’t there.
You will need to clone the “baller” that is currently in replicated storage and parent it to the “collectedFile”.
--Insert this after local collectedFile = player.MemesCollected
local clone = Baller:Clone()
clone.Parent = collectedFile
local found = collectedFile:FindFirstChild("Baller") --You won't actually need this line, you can just refer to the clone (just left it in to demonstrate)
print(found, found.Value) --Should now print Baller with any default value it had already been given whilst in rep storage