How can I get this piano working again or is it beyond the point of repair?
Hey, guys! I'm here due to my script not being able to work. The piano is supposed to play a sound (note) when you press certain keys on your keyboard but as you can see, it is not working.
Please help because I have no clue why this isn't working.
Here are my scripts.
Normal script:
02 | local KeyTool = script [ "PianoPlayer V1.1" ] :Clone() |
03 | script [ "PianoPlayer V1.1" ] :Remove() |
04 | position = script.Parent.Archive.Position |
05 | local frame = Instance.new( "CFrameValue" ) |
06 | frame.Name = "OriginCFrame" |
07 | frame.Value = script.Parent.Archive.CFrame |
08 | frame.Parent = script.Parent |
10 | local object = Instance.new( "ObjectValue" ) |
11 | object.Value = script.Parent.Parent.Parent |
13 | seat = script.Parent.Seat |
15 | function onSitUp(child, hopper, piano, object) |
17 | if child.Parent = = nil then |
24 | function onChildAdded(part) |
25 | if part.className = = "Weld" then |
26 | local torso = part.Part 1 |
28 | local parent = torso.Parent |
32 | local char = torso.Parent |
33 | local player = game.Players:GetPlayerFromCharacter(char) |
35 | local hopper = KeyTool:clone() |
36 | hopper.Parent = player.Backpack |
37 | local object = script [ "Instrument" ] :clone() |
38 | object.Value = script.Parent.Parent |
40 | part.AncestryChanged:connect( function (child) onSitUp(child, hopper, script.Parent.Parent, object) end ) |
46 | seat.ChildAdded:connect(onChildAdded) |
47 | seat.BrickColor = BrickColor.new( "Really black" ) |
Main Script:
03 | function findPiano(player) |
04 | local list = player.Character:GetChildren() |
06 | if (list [ x ] .Name = = "Instrument" ) then |
07 | local weld = list [ x ] .Value:FindFirstChild( "Parts" ):FindFirstChild( "Seat" ):FindFirstChild( "SeatWeld" ) |
08 | if (weld ~ = nil ) and (weld.Part 1 = = player.Character:FindFirstChild( "Torso" )) then |
16 | function onSelected(mouse) |
18 | mouse.KeyDown:connect(onKeyDown) |
21 | function onKeyDown(key) |
24 | local piano = findPiano(script.Parent.Parent.Parent) |
25 | if (piano = = nil ) then return end |
27 | local archive = piano.Parts.Archive |
29 | archive:findFirstChild( "0" ).Run.Value = true |
32 | archive:findFirstChild( "0s" ).Run.Value = true |
35 | archive:findFirstChild( "1" ).Run.Value = true |
38 | archive:findFirstChild( "2b" ).Run.Value = true |
41 | archive:findFirstChild( "3" ).Run.Value = true |
44 | archive:findFirstChild( "4" ).Run.Value = true |
47 | archive:findFirstChild( "4s" ).Run.Value = true |
50 | archive:findFirstChild( "5" ).Run.Value = true |
53 | archive:findFirstChild( "5s" ).Run.Value = true |
56 | archive:findFirstChild( "6" ).Run.Value = true |
59 | archive:findFirstChild( "6s" ).Run.Value = true |
62 | archive:findFirstChild( "7" ).Run.Value = true |
65 | archive:findFirstChild( "8" ).Run.Value = true |
68 | archive:findFirstChild( "8s" ).Run.Value = true |
71 | archive:findFirstChild( "9" ).Run.Value = true |
74 | archive:findFirstChild( "9s" ).Run.Value = true |
77 | archive:findFirstChild( "10" ).Run.Value = true |
80 | archive:findFirstChild( "11" ).Run.Value = true |
83 | archive:findFirstChild( "11s" ).Run.Value = true |
88 | bin.Selected:connect(onSelected) |
Lighting script:
1 | script.Parent.Parent = game:service( "Lighting" ) |
Sound Script:
05 | local Sound = script.Parent |
11 | if Bool.Value = = true then |
19 | Bool.Changed:connect(Play) |
Hope you guys know how to solve this!