Beat Game Track Script

You can write your topic however you want, but you need to answer these questions:

  1. Fix the script

  2. Errors, code:

wait(1)
local TweenService = game:GetService("TweenService")
local trackdata = require(script.Parent.Track)
local Song = trackdata.Song
local Track = trackdata.Rythm

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

local StartTick = tick()

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

while true do
	wait(.1)
	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 = workspace.Game:FindFirstChild(v.."Start")
			local Finish = workspace.Game: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 == "A" then
				    Key:SetPrimaryPartCFrame(Key.PrimaryPart.CFrame*CFrame.Angels(math.rad(90),0,0))
				elseif v == "S" then
				    Key:SetPrimaryPartCFrame(Key.PrimaryPart.CFrame*CFrame.Angels(math.rad(180),0,0)
				elseif v == "D" then
					Key:SetPrimaryPartCFrame(Key.PrimaryPart.CFrame*CFrame.Angels(math.rad(-90),0,0)
				end
				for q,r in pairs(Key:GetChildren()) do
					local Goal = {}
					Goal.CFrame = r.CFrame*CFrame.new(Distance,0,0)
					local tweeni = TweenInfo.new(5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut)
					local tween = TweenService:Create(r,tweeni,Goal)
					tween:Play()
					spawn(function()
						wait(5)
						local Goal = {}
						Goal.Transparency = 1
						local tweeni = TweenInfo.new(1)
						local tween = TweenService:Create(r,tweeni,Goal)
						tween:Play()
						wait(1)
						r.Parent:Destroy()
				end)
			end
		end
	end
end

The error: image

  1. I tried looking on devforum.

I am currently making a game similar to RoBeats and the track script ain’t working. Anyone has any ideas? (Spent 30 minutes on trying to solve error)

Looks like there is few issues is here.

  1. There is no CFrame.Angels constructor; however there is a CFrame.Angles constructor.
  2. You are missing a closing ) on line 34 and 36.
  3. You’re missing an end
    at the very end of your code.

Overall you would want to change your code to look something this:

				if v == "A" then
				    Key:SetPrimaryPartCFrame(Key.PrimaryPart.CFrame*CFrame.Angles(math.rad(90),0,0))
				elseif v == "S" then
				    Key:SetPrimaryPartCFrame(Key.PrimaryPart.CFrame*CFrame.Angles(math.rad(180),0,0))
				elseif v == "D" then
					Key:SetPrimaryPartCFrame(Key.PrimaryPart.CFrame*CFrame.Angles(math.rad(-90),0,0))
				end

This isn’t the full code, but it is a good start to tell you where to go.

1 Like

Lines with the S and D have a right bracket ) missing at the end.