- What do you want to achieve? I want to make a music note go into a player’s torso when they press on their screen. Once the note goes to the torso it will destroy itself. Not sure why my script is erroring. I basically want the pathfinding service to make the object go in this path.
- What is the issue? The 1st issue is the music note isn’t going where I want it to go, it just falls under the player (the part is anchored). 2nd is I’m not really sure how to get the music note into the motion I want it to. I added a part that indicates the endpoint (which is transparent behind the head of the player) of the music note. That part also falls. Here’s my code.
local DataStoreV2 = require(1936396537)
local Player = script.Parent.Parent.Parent
local Character = Player.Character
local MusicDS = DataStoreV2("MusicDataStore2", Player)
local TotalMusicDS = DataStoreV2("TotalMusicDataStore2", Player)
local AlbumDS = DataStoreV2("AlbumDataStore2", Player)
local Debounce = false
local DesiredAmount = 5
local MusicNote = game.ReplicatedStorage.Objects.MusicNoteSystem.MusicNote:Clone()
local endPoint = game.ReplicatedStorage.Objects.MusicNoteSystem.endPoint:Clone()
local PathParts = Instance.new("Model", Head)
PathParts.Name = "PathParts"
local function ShowMusicNote()
local Head = Character.Head
MusicNote.Position = Vector3.new(Head.Position.X, Head.Position.Y, Head.Position.Z - 10)
MusicNote.Parent = Head
endPoint.Parent = Head
endPoint.Position = Vector3.new(Head.Position)
local PathFindingService = game:GetService("PathfindingService")
local Path = PathFindingService:CreatePath()
Path:ComputeAsync(MusicNote.Position, endPoint.Position)
local Waypoints = Path:GetWaypoints()
for i = 1,5 do
if i < #Waypoints then
local Tracker = Instance.new("Part")
Tracker.Anchored = true
Tracker.Size = Vector3.new(0.5,0.5,0.5)
Tracker.Position = Waypoints[i].Position
Tracker.CanCollide = false
Tracker.Transparency = 1
MusicNote.Position = Waypoints[i].Position
wait(.1)
end
end
end
--Everything from here down works!
script.Parent.Activated:Connect(function()
if Debounce == false then
if Player.PlayerValues.Music.Value < Player.PlayerValues.Album.Value then
Debounce = true
-- TotalMusicDS:Increment(DesiredAmount, 0)
-- MusicDS:Increment(DesiredAmount, 0)
ShowMusicNote()
wait(2)
Debounce = false
end
end
end)
If anyone knows the issue or a solution please let me know!