Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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
0
did it clone in your inventory or clone on the floor? Galaxybombboy 134 — 4y
0
In the position you found it RedKylegamer123 2 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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?

0
The tool is floating in the air so it isn't touching anything RedKylegamer123 2 — 4y
0
still , try it. i'll try to come up with another solution Galaxybombboy 134 — 4y
0
Nope it didn't work RedKylegamer123 2 — 4y
0
Then why did you accept my answer Galaxybombboy 134 — 4y
Ad

Answer this question