How can i add a delay to this system?

image
They still just sit off the head and fall off

Alright, try now? I edited the drop script to parent the drop model to the workspace.Drops folder first. Have a hunch…

1 Like

LEGEND! Thank you sosoosososososo much!!!

This has been a painful experience lol. Glad to get it over with

Thank you so much!

1 Like

Wait. Now i cant collect coins

AHHHHHHHHHHHHHHHHHHHHHHH IM NOT EVEN RELIGIOUS BUT I BET THIS IS GODS DOINGGG

Finally lol! Glad I could help! I’m glad that’s over. I know what it’s like to not find any help. Actually I never really post on the DevForum (too much work), but maybe I will now. :slight_smile: Very time consuming though not gonna lie. Well, great! Hope your game goes well. Happy (albeit frustrating) scripting! :stuck_out_tongue:

Wait what- NOOOOOO

1 Like

It was it this moment he knew. He messed up.

I Think i know why. The coins are parts. so you have done something to make it a model. ill try fix it aswell

Alright, here we go again :joy:. One more question. When you say it won’t collect, do you mean the coins aren’t reacting to the player (they aren’t flying toward them) or they do fly toward them, but the player’s currency doesn’t go up? Depending on this I might have a solution

1 Like

Wait, the coins are collecting. just extremely late

there collecting now?

I only start collecting them after 15 seconds from when they spawn. then i can collect them like before

Nevermind, now its working lol. Guess i fixed it. Thanks for the help :smiley:

Alright, I think I know. To simplify things, I used the pivot of the model rather than the coins themselves to detect if the player was close enough. However, the model’s pivot is relative to the originCFrame, so it’ll only collect when you get close to where the coins started from, not the coins themselves. I thought it’d be simpler than iterating over each coin to see if one were close enough, but it seems that’s how it should be. I’ll edit it one last time, then hope and pray it’s over :pray:- oh you already fixed it XD Well regardless I’ll edit my solution to check each coin’s position instead of the model’s pivot. Sorry for any trouble you’ve had lol, it sure is a great test of patience. :slight_smile:

Heh, only took 72 posts to solve your problem haha

Edited it one last time. Phew

1 Like

Yeah lol, if i have any major issues in the future. ill come to you (as long as it doesn’t take 4 hours are 72 posts to resolve. At that point ill just give up)

Thanks again. I can now live relaxed- THEY’RE BROKEN AGAIN!

jk. Again, thanks for the help! Have a good rest of your day :slight_smile:

1 Like

I know the problem was already solved, but you could’ve just added a task.delay.

Code:

local player  = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local ts = game:GetService("TweenService")
local rs = game:GetService("ReplicatedStorage")

while task.wait() do
	for i, drop in pairs(workspace.Drops:GetChildren()) do
		if drop:IsA("Part") and not drop:GetAttribute("Collected") and drop:FindFirstChild("Value") then
			local magnitude = (HumanoidRootPart.Position - drop.Position).Magnitude
			if magnitude <= player.Data.MagnetReach.Value then
				drop:SetAttribute("Collected", true)
				
				task.delay(2, function()
					local value = drop:WaitForChild("Value").Value
					local CurrencyName = drop:WaitForChild("CurrencyName").Value
					drop.CanCollide = false
					
					local tween = ts:Create(drop, TweenInfo.new(magnitude * 0.01, Enum.EasingStyle.Sine), {Position = HumanoidRootPart.Position})
					tween:Play()
					tween.Completed:Wait()
					
					rs:WaitForChild("GiveCurrency"):FireServer(CurrencyName, value)
					drop:Destroy()
					rs:WaitForChild("Sounds").Collect:Play()
				end)
			end
		end
	end
end
1 Like

But wouldn’t this only collect 1 coin every 2 seconds

No, task.delay runs the section in a new “thread” so the wait doesn’t impact anything else.

1 Like
  1. 72 REPLIES ON THIS POST. AND I COULD HAVE DONE THAT?

dang, i feel bad for everyone ngl lol.

Thanks anyways :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.