I have a ModuleScript in workspace
that will clone a model of a note for a rhythm game. My ModuleScript is called with require()
in a LocalScript in StarterPlayerScripts. The script below will actually clone the object just fine, but it won’t move it to the position I want it to go.
function note(_time, track)
if track > 4 or track < 1 then
warn(warningMessageInvalidTrack)
end
if _time > math.floor((workspace.MUSIC.TimeLength)*1000) then
warn(warningMessageInvalidTime)
end
repeat
wait(0)
until workspace.songPosition.Value > _time --Waits until the song position is greater than a certain value
local original = workspace.InGameObjects.Note --19 thru 21 copies the part and parents it
local copy = original:Clone()
copy.Parent = original.Parent
local t = 0 --"t" will reperesent the X coordinate for the corresponding track
if track == 1 then
t = -8.68
end
if track == 2 then
t = -1.68
end
if track == 3 then
t = 5.32
end
if track == 4 then
t = 12.32
end
local y_pos = 0.133
local z_pos = -9.435
copy.Position = Vector3.new(t,y_pos,z_pos) -- y_pos and z_pos are constants, meaning they don't "adapt" to the track number.
end