Attempt to index a nil value when destroying?

So I have this server script that when fired it should delete a thing called “Controller” from the character, but its giving a nil value error? any help?

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local createPartEvent = Instance.new("RemoteEvent", ReplicatedStorage)

createPartEvent.Name = "RemoveControllerB"

local function onCreatePartFired(player)

local character = player.Character

character:FindFirstChild("Controller"):Destroy()

game.Workspace.ControllerB.Occupied.Value = false

end

createPartEvent.OnServerEvent:Connect(onCreatePartFired)

Do you know if your event listener function is firing twice? if so the Controller would be nil.

Show the part of code were the Child(‘Controller’) is Created/Inserted into the character.

I just facepalmed, I cloned it locally and gave it to the player, No wonder the server isn’t picking it up.

thats a big oof. So it works now?

Im editing the code a little bit so it works.

2 Likes