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

Why can I not seem to get more than 1 note out at once?

Hello, I am making a Rhythm game and when I coded the notes the intentions were to approach quick and in a large group not one at a time, which they did. I tried my best to combat this, but no results. Please help me.

wait(1)

local TweenService = game:GetService("TweenService")
local TrackData = require(script.Parent.Rythm)
local Song = TrackData.Song
local Speed = TrackData.AppTime
local Track = TrackData.Rythm
local function Destroy(r)
	wait(.3)
	r.Parent:Destroy()
end
local function Tween(Key,Distance)
	for q,r in pairs(Key:GetChildren()) do
		local Goal = {}
		wait()
		Goal.CFrame = r.CFrame*CFrame.new(Distance,0,0)
		local Tweeni = TweenInfo.new(.3,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut)
		local tween = TweenService:Create(r,Tweeni,Goal)
		tween:Play()
		Destroy(r)
	end
end

script.Sound.SoundId = "rbxassetid://"..Song

local StartTick = tick()

spawn(function()
	repeat wait() until tick() - StartTick >= 5
	script.Sound:Play()
end)

while true do
	wait()
	local Second = tick() - StartTick
	Second = Second * 10
	Second = math.floor(Second)
	Second = Second / 10
	for i,v in pairs(Track) do
		if i == Second then
			local Start = game.Workspace.Notes:FindFirstChild(v.."Note")
			local Finish = game.Workspace.Notes:FindFirstChild(v.."Finish")
			if Start and Finish then
				local Key = game.ReplicatedStorage.Key:Clone()
				Key.Parent = workspace
				Key:SetPrimaryPartCFrame(Start.CFrame)
				local Distance = (Start.Position-Finish.Position).magnitude
				if v == "Left" then
					Key.LeftFinish.BrickColor = BrickColor.Red()
					Key:SetPrimaryPartCFrame(Key.PrimaryPart.CFrame*CFrame.Angles(math.rad(180),0,0))
				end
				if v == "Center" then
					Key.LeftFinish.BrickColor = BrickColor.new("Really blue")
					Key:SetPrimaryPartCFrame(Key.PrimaryPart.CFrame*CFrame.Angles(math.rad(180),0,0))
				end
				if v == "Right" then
					Key.LeftFinish.BrickColor = BrickColor.new("New Yeller")
					Key:SetPrimaryPartCFrame(Key.PrimaryPart.CFrame*CFrame.Angles(math.rad(180),0,0))
				end
				wait()
				Tween(Key,Distance)
			end
		end
	end
end

1 comment

0

FYI The map I am mapping is: Jauz x San Holo - OK!

1 answer

✓ Accepted answer

Use coroutines that way all the notes can move at the same time toward the large group instead of at a time

3 comments

0

Can you explain this better? I have no clue what to do with them.

0

Can you explain this better? I have no clue what to do with them.

0

well i linked the article about coroutines they explain it pretty well, basicaclly you give that a function and it acts like its excuting from a different script so that this script can continue on, what ur doing is now looping over each note and telling it to go to a different position one by one

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