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

Why is my touch event running over and over crashing my roblox studio?

I am trying to make it so when you touch the tool it will give you it but also clones itself so that it will be in the same spot where you found it, just in case another player comes to get it.

My code:

local Tool = script.Parent.Parent
local handle = script.Parent

handle.Touched:Connect(function() 
	Tool.Equipped:Connect(function()
		local TC = Tool:Clone()
			
			TC.Position = Vector3.new(47.909, 2075.744, 180.469)
			TC.Parent = workspace
			
			end)
	end)

The code was successful in:

  • Cloning
  • Parent set to workspace
  • Position set to where it was found

Failures:

  • Cloned multiple times crashing my roblox studio

What I have tried:

  • I tried using debounce but it didn't work and I don't know why

2 comments

0

did it clone in your inventory or clone on the floor?

0

In the position you found it

1 answer

✓ Accepted answer

i dont know If this will work. But try this

local Tool = script.Parent.Parent
local handle = script.Parent
 
handle.Touched:Connect(function(hit) 
if hit.Parent:FindFirstChild("Humanoid") then
    Tool.Equipped:Connect(function()
        local TC = Tool:Clone()

            TC.Position = Vector3.new(47.909, 2075.744, 180.469)
            TC.Parent = workspace
		script.Disabled = true
wait(5)
		script.Disabled = false
		
 		end
            end)
    end)

the reason it might work is cause. yes. you touch It and it clones. gives you the thing. blah. but then. maybe it thinks it keeps touching the ground so it keep cloning? also you might have to add another "end" cause I dont know, I didn't write this in roblox studio. just try it?

4 comments

0

The tool is floating in the air so it isn't touching anything

0

still , try it. i'll try to come up with another solution

0

Nope it didn't work

0

Then why did you accept my answer

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