Exception while signaling: Must be a LuaSourceContainer

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

making a mining game

  1. What is the issue? Include screenshots / videos if possible!

exception while signaling: Must be a LuaSourceContainer printed 3225 times

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    no
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
i couldnt found where was the error was coming

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

its printing 4K times and breaking my game

I have no idea where to start. Do you have any code that causes the errors?

Also I read the documentation on LuaSourceContainer, which reads that it is the source of all scripts.

wait

it was comming from my 4k coin collectors

i deleted them and it works fine
but i might try to add a new one without printing 4k times

but thank you for helping me

i think these parts are useless and might cause lag

I can still try and fix the error. Just paste the script segment that errors.

1 Like

Alright. If you want to just remake it, I don’t mind.

1 Like

wait wait i think the error was comming from this script

amnt = 700 --how much you get for it
function onTouched(part)
	local h = part.Parent:findFirstChild("Humanoid")
	if (h~=nil) then
		local thisplr = game.Players:findFirstChild(h.Parent.Name)
		if (thisplr~=nil) then
			local stats = thisplr:findFirstChild("leaderstats")
			if (stats~=nil) then
				local score = stats:findFirstChild("Blocks")
				if (score~=nil) then
					score.Value = score.Value + amnt
				end
			end
		end
		script.Parent:remove()
	end
end

script.Parent.Touched:connect(onTouched)
amnt = 700 --how much you get for it
function onTouched(part)
	local h = part.Parent:findFirstChild("Humanoid")
	if h then
		local thisplr = game.Players:findFirstChild(h.Parent.Name)
		if thisplr then
			local stats = thisplr:findFirstChild("leaderstats")
			if stats then
				local score = stats:findFirstChild("Blocks")
				if score then
					score.Value += amnt
				end
			end
		end
		script.Parent:remove()
	end
end

script.Parent.Touched:connect(onTouched)

I can’t find any errors, but I polished your code. Is the first parameter, part, being returned in a print()?

wait let me try it…

because idk why

uhh the problem isnt occuring anymore i will tell you if it happens

1 Like

Mabye it was your coding style. It’s really messy, and definitely needed some polishing.

wait a minute…

it stopped happening and then it starts and stops what is happening over here

i need to remove the thing so it dosent break the players computer fan

1 Like

Switch your code out with this:

--//Services
local Players = game:GetService("Players")

--//Variables
local Part = script.Parent

--//Controls
local amount = 700

--//Functions
Part.Touched:Connect(function(hit)
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	
	if player then
        Part:Destroy()

		player.leaderstats.Blocks.Value += amount
	end
end)
2 Likes

I see an error in your code:

Part, the parent of script, gets deleted before anything can be done. This renders the leaderstats value unreachable.

Correct me if I’m wrong.

1 Like

No it doesn’t. If you know anything about how scripts/threads run, the entire thread runs even if the parent was destroyed first.

Ah. That makes sense, after testing. I still find it strange to delete the parent before any changes.

1 Like

I delete the parent first so that in the split milliseconds that it takes for the value to add, the player can’t fire the touched event again. It’s just a prevention for that edgecase.

2 Likes