
KeylessUniversal

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local HitEvent = ReplicatedStorage:WaitForChild("NoteHit")
local AUTO_PLAY = true
-- Maximum timing difference allowed
local HIT_WINDOW = 0.12
local alreadyHit = {}
local validDirections = {
Left = true,
Down = true,
Up = true,
Right = true
}
local function hit(note)
if alreadyHit[note] then
return
end
if not note or not note.Parent then
return
end
local direction = note:GetAttribute("Direction")
if not validDirections[direction] then
warn("Invalid note direction:", direction)
return
end
alreadyHit[note] = true
-- Send the hit to your game's normal scoring system
HitEvent:FireServer(note, direction)
-- Cleanup
task.delay(1, function()
alreadyHit[note] = nil
end)
end
local function checkNotes()
if not AUTO_PLAY then
return
end
local now = workspace:GetServerTimeNow()
for _, note in ipairs(CollectionService:GetTagged("RhythmNote")) do
if note.Parent then
local hitTime = note:GetAttribute("HitTime")
if typeof(hitTime) == "number" then
local difference = hitTime - now
-- Hit when the note reaches the hit time
if math.abs(difference) <= HIT_WINDOW then
hit(note)
end
end
end
end
end
RunService.Heartbeat:Connect(checkNotes)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")
local HitEvent = ReplicatedStorage:WaitForChild("NoteHit")
local VALID_DIRECTIONS = {
Left = true,
Down = true,
Up = true,
Right = true
}
local HIT_WINDOW = 0.2
HitEvent.OnServerEvent:Connect(function(player, note, direction)
if not note then
return
end
if not note:IsDescendantOf(game) then
return
end
-- Make sure this is actually one of our rhythm notes
if not CollectionService:HasTag(note, "RhythmNote") then
return
end
if not VALID_DIRECTIONS[direction] then
return
end
local noteDirection = note:GetAttribute("Direction")
local hitTime = note:GetAttribute("HitTime")
if noteDirection ~= direction then
return
end
if typeof(hitTime) ~= "number" then
return
end
local currentTime = workspace:GetServerTimeNow()
if math.abs(currentTime - hitTime) > HIT_WINDOW then
return
end
------------------------------------------------
-- YOUR SCORING CODE GOES HERE
------------------------------------------------
print(player.Name .. " AUTO HIT:", direction)
-- Example:
-- player.leaderstats.Score.Value += 100
-- Remove the note
note:Destroy()
end)No comments yet for this script.



