I cant figure out the error in this script?
bin=script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
function findPlane(player)
local list = player.Character:GetChildren()
for x = 1, #list do
if (list[x].Name == "Cat") then --Put model name here--
local weld = list[x]:FindFirstChild("Parts"):FindFirstChild("Seat"):FindFirstChild("SeatWeld")
if (weld ~= nil) and (weld.Part1 == player.Character:FindFirstChild("Torso")) then
return list[x]
end
end
end
return nil
end
function onSelected(mouse)
mouse.KeyDown:connect(onKeyDown)
end
function onKeyDown(key)
if (key~=nil) then
key = key:lower()
local Test = game.Workspace.Cat -- LINE 23 -- Replace X with Main Vehicle Model Name
if (Key:byte() == 56) then -- Reverse
script.Value.Value = -1
end
if (Key:byte() == 50) then --Move
script.Value.Value = 1
end
if (Key:byte() == 54) then --Stop
script.Value.Value = -1
end
if (Key:byte() == 52) then --Return
script.Value.Value = 1
end
if (script.Value.Value == 3) then --stop--
Test.Part0.Motor.DesiredAngle = 0
end
if (script.Value.Value == 0) then --Door closed--
Test.Part0.Motor.DesiredAngle =math.rad(-135)
wait(0.01)
end
if (script.Value.Value == 2) then --stop--
Test.Part0.Motor.DesiredAngle =Test.Part0.Motor.CurrentAngle + math.rad(0)
end
if (script.Value.Value == 1) then --Door open--
Test.Part0.Motor.DesiredAngle =math.rad(135)
wait(0.01)
end
bin.Selected:connect(onSelected)
function onSelected(mouse)
mouse.KeyDown:connect(onKeyDown)
end
function onKeyUp(key)
if (key~=nil) then
key = key:lower()
local Test = game.Workspace.Cat -- LINE 23 -- Replace X with Main Vehicle Model Name
if (Key:byte() == 56) then -- Reverse
script.Value.Value = -1
end
if (Key:byte() == 50) then --Move
script.Value.Value = 1
end
if (Key:byte() == 54) then --Stop
script.Value.Value = -1
end
if (Key:byte() == 52) then --Return
script.Value.Value = 1
end
if (script.Value.Value == -1) then --stop--
Test.Part0.Motor.DesiredAngle = 0
end
if (script.Value.Value == 1) then --Door closed--
Test.Part0.Motor.DesiredAngle =math.rad(-135)
wait(0.01)
end
if (script.Value.Value == -1) then --stop--
Test.Part0.Motor.DesiredAngle =Test.Part0.Motor.CurrentAngle + math.rad(0)
end
if (script.Value.Value == 1) then --Door open--
Test.Part0.Motor.DesiredAngle = Test.Part0.Motor.CurrentAngle + math.rad(10)
wait(0.05)
end
bin.Selected:connect(onSelected)
function onSelected(mouse)
mouse.KeyUp:connect(onKeyUp)
end
end