Getting the error: ServerScriptService.BunnyHandler.MainBunny:35: attempt to concatenate string with nil please help

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:35: attempt to concatenate string with nil How Do I fix this?

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 ReplicatedCore = require(ReplicatedStorage:WaitForChild('Core'))
local ReplicatedData = ReplicatedCore.ReplicatedData

local ServerService = game:GetService('ServerStorage')
local ServerCore = require(ServerService:WaitForChild('Core'))

local BunnyTouchedEvent = RemoteModule:GetRemote('BunnyTouched', 'RemoteEvent', false)

local Module = {}

function Module:CheckBunny(bunnyID)	
	for i, Bunny in pairs(BunnyFolder:GetChildren()) do
		if Bunny:IsA('Part') and Bunny.Parent == BunnyFolder then
				local LocalPlayer = Players:GetPlayerFromCharacter(Hit.Parent)
				local profile = ServerCore.DataService:GetPlayerProfile(LocalPlayer)
				if not profile then
					warn('No Player Profile!')
				local BunnyConfig = ReplicatedModules.Bunnys:GetItemConfig(bunnyID)
				if not BunnyConfig then
					warn('No Item Config For' ..bunnyID)
				BunnyTouchedEvent:FireClient(LocalPlayer, Bunny)
				table.insert(profile.Data.BunniesFound, bunnyID)
				print('Bunny Was Touched')
			warn('Touched Part Not From Bunny Folder')

return Module

What are you passing when calling this function? The error means you tried to combine a string and a nil value.

Here is the script for the function

	for _, itemData in ipairs(Module.Bunnys) do
		if itemData.ID == BunnyID then
			return itemData
	return nil

I do have the ID’s listed in the module as well.

When you call Module:CheckBunny() what do you put as the first parameter? If the first parameter is nil or you don’t put one, you will get that error.

1 Like