Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I got a funny error(maximum event re-entrancy depth exceeded)?

I think the error is because I'm doing something to many times, but this doesn't seam like it.. I don't know what I'm doing wrong, do you?

wait(.1)
local player=game.Players.LocalPlayer
local building=game.ReplicatedStorage.Buildings:FindFirstChild("Hut")
script.Parent.Equipped:connect(function(mouse)
copy=building:Clone()
copy.Parent=player.Character
end)

4 comments

1

That error happens when events trigger off of each other too many times. All I can suggest here is to check if the "Hut" is connecting an event that causes an event triggering loop to occur.

0

I checked, and there is nothing connecting it to the "Hut", but is it bad that it's in a "BackPack" object?

1

That shouldn't matter. Sorry guy, I can't help ya.

0

Okay, thanks, I'll try to do something else.

2 answers

Put a wait(0.01) after the Equipped event, like this:

wait(.1)
local player=game.Players.LocalPlayer
local building=game.ReplicatedStorage.Buildings:FindFirstChild("Hut")
script.Parent.Equipped:connect(function(mouse)
	wait(0.01)
	copy=building:Clone()
	copy.Parent=player.Character
end)

It should work

This discussion is preserved as it was. New answers, comments, and votes are closed.