Scxiptifyz
(Scxiptifyz)
December 11, 2022, 3:45pm
#1
Hello Roblox!
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.
DevLazl
(Lazl)
December 11, 2022, 3:54pm
#2
Put the touched event in a separate script and work from there
1 Like
Xacima
(Yui)
December 11, 2022, 3:54pm
#3
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
Scxiptifyz
(Scxiptifyz)
December 11, 2022, 3:57pm
#4
Thank you! where would i put that? where it says task.wait?
Xacima
(Yui)
December 11, 2022, 3:58pm
#5
task.spawn(function()
-- Your loop.
end)
1 Like
Scxiptifyz
(Scxiptifyz)
December 11, 2022, 3:59pm
#6
Thank you, and finally. do i still need the task.wait(1) function?
Xacima
(Yui)
December 11, 2022, 3:59pm
#7
Yes, if not your script will crash/time out.
1 Like
Scxiptifyz
(Scxiptifyz)
December 11, 2022, 4:00pm
#8
Ok, Thank you so much! Have a good day!
Scxiptifyz
(Scxiptifyz)
December 11, 2022, 4:02pm
#10
Its still not working for me
(char bypass)
R_obotz
(Robotz)
December 11, 2022, 4:03pm
#11
Because instead of hit.Parent:FindFirstChild("Humanoid")
you did hit:FindFirstChild("Humanoid")
Let me know if it’s not solved yet.
1 Like
Xacima
(Yui)
December 11, 2022, 4:03pm
#12
Show me the updated code.
And, check for errors first.
1 Like
Scxiptifyz
(Scxiptifyz)
December 11, 2022, 4:04pm
#13
If that works im going to slap myself
Scxiptifyz
(Scxiptifyz)
December 11, 2022, 4:05pm
#14
its still not working, sorry. atleast i dont have to slap myself
Egzekiel
(Egzekiel)
December 11, 2022, 4:06pm
#15
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
Scxiptifyz
(Scxiptifyz)
December 11, 2022, 4:08pm
#17
I can’t. it just highlights the line where i clone the iron drop.
Egzekiel
(Egzekiel)
December 11, 2022, 4:10pm
#18
Send a screenshot.
zzzzzzzzzzzzzzzzzzzzzzzzzzz
1 Like
R_obotz
(Robotz)
December 11, 2022, 4:11pm
#20
Did you make sure to put the Touched
event inside the while
loop as @Egzekiel suggested?
1 Like