Hello! I am Dev_Asher and I am working on a find the markers game remake, I made a script where when the player touched a marker or in this case Bunny, it fires a remote event to the client where it will reward the player for finding the Bunny. But now when I Fire the client it gives me an error saying ServerScriptService.BunnyHandler.MainBunny:28: invalid argument #1 to ‘pairs’ (table expected, got nil) Does anyone know how to fix this?
local HTTPService = game:GetService('HttpService')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Players = game:GetService('Players')
local BunnyFolder = workspace:WaitForChild('BunnysFolder')
local ReplicatedModules = require(ReplicatedStorage:WaitForChild('Modules'))
local RemoteModule = ReplicatedModules.RemoteService
local BunnysModule = ReplicatedModules.Bunnys
local SystemsContainer = { }
local BunnyTouchedEvent = RemoteModule:GetRemote('BunnyTouched', 'RemoteEvent', false)
local selectedData = nil
local Module = {}
function Module:BunnyStack(BunnyID)
return {
ID = BunnyID,
UUID = HTTPService:GenerateGUID(false)
}
end
function Module:SetProperties(Parent, propertiesTable)
for guiObjctName, labelProperties in pairs(propertiesTable) do
local targetGuiObject = Parent:FindFirstChild(guiObjctName)
if targetGuiObject and targetGuiObject:IsA('Frame') then
targetGuiObject = targetGuiObject:FindFirstChild('Label')
end
if not targetGuiObject then
continue
end
for propertyName, propertyValue in pairs(labelProperties) do
targetGuiObject[propertyName] = propertyValue
end
end
end
function Module:CheckBunnyFromID(BunnyID)
for i, Bunny in pairs(BunnyFolder:GetChildren()) do
if Bunny:IsA('Part') and Bunny.Parent == BunnyFolder then
Bunny.Touched:Connect(function(Hit)
local LocalPlayer = Players:GetPlayerFromCharacter(Hit.Parent)
BunnyTouchedEvent:FireClient(LocalPlayer, Bunny)
local Interface = LocalPlayer:WaitForChild('PlayerGui'):WaitForChild('Ui_Interface')
local FoundBunnyUI = Interface:WaitForChild('BunnyFound')
local LHUD = Interface:WaitForChild('LHUD')
local selectedConfig = selectedData and BunnysModule:GetItemConfig(selectedData.ID)
FoundBunnyUI.Visible = true
LHUD.Visible = false
FoundBunnyUI.Icon.Image = Module:SetProperties(FoundBunnyUI.Icon.Image, BunnyID)
wait(5)
FoundBunnyUI.Visible = false
LHUD.Visible = true
warn('Bunny Was Touched')
end)
else
warn('Touched Part Not From Bunny Folder')
end
end
end
function Module:Init(otherSystems)
SystemsContainer = otherSystems
end
return Module