:Touched() Not Working After Tween

Hello Roblox! :wave:

I’m trying to achieve a bed-wars style generator. However, after the tween. The Game wont do anything after i touch it. I need it the value of Iron in Leaderstats to go up. Here is my code. And if you need to see the top part (leaderstats & Variables) Please let me know asap.

Put the touched event in a separate script and work from there

1 Like

Because you’re never exiting the loop, so the code doesn’t run anything below the loop.
Wrap the loop in a task.spawn() function.

1 Like

Thank you! where would i put that? where it says task.wait?

task.spawn(function()
   -- Your loop.
end)
1 Like

Thank you, and finally. do i still need the task.wait(1) function?

Yes, if not your script will crash/time out.

1 Like

Ok, Thank you so much! Have a good day!

You’re welcome.
You too.

(30 letters bypass)

1 Like

Its still not working for me

(char bypass)

Because instead of hit.Parent:FindFirstChild("Humanoid") you did hit:FindFirstChild("Humanoid")

Let me know if it’s not solved yet.

1 Like

Show me the updated code.
And, check for errors first.

1 Like

If that works im going to slap myself

its still not working, sorry. atleast i dont have to slap myself

You create the object inside the loop, therefore, you need to have a Touched event for every object you create.

The fix is to place the whole Touched event and its content inside the loop.

Also, make sure to add a “local” in front of IronDropClone = IronDrop:Clone()

1 Like

image

I can’t. it just highlights the line where i clone the iron drop.

Send a screenshot.

zzzzzzzzzzzzzzzzzzzzzzzzzzz

1 Like

Did you make sure to put the Touched event inside the while loop as @Egzekiel suggested?

1 Like